【问题标题】:How to retreive DependentUpon property of EmbeddedResource in a C# project如何在 C# 项目中检索 EmbeddedResource 的 DependentUpon 属性
【发布时间】:2017-10-18 04:24:03
【问题描述】:

我有一个小程序,可以从解决方案中项目的 .resx 文件中检索资源字符串。该项目是使用访问 Microsoft.Build.Execution.ProjectInstance() 然后我们遍历 Items 集合中的 Microsoft.Build.Execution.ProjectItemInstance 项。

在这个程序中提取一些 .resx 文件和相关项目之间的关系会很有帮助,例如 Form1.cs、Form1.resx 和 Form1.fr-CA.resx。我可以在 .csproj 文件中看到它们使用 DependentUpon 属性相关。不幸的是,该属性似乎没有在 Microsoft.Build.Execution.ProjectItemInstance 中公开。

如何检索项目的 EmbeddedResource 项的 DependentUpon 属性?本程序的环境为VS2015;它正在浏览的解决方案和项目是 VS2008 Compact Framework 3.5。

【问题讨论】:

    标签: msbuild


    【解决方案1】:

    您应该能够使用GetMetadataValue() 函数来检索元数据值。

    var dependentUponValue = itemInstance.GetMetadataValue("DependentUpon");
    

    请注意,如果请求的元数据未在项目上定义,这可能会返回一个空字符串。

    【讨论】:

      猜你喜欢
      • 2011-08-03
      • 2018-10-19
      • 2020-09-05
      • 2022-09-26
      • 2019-09-13
      • 2014-01-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多