[英]C# Visual Studio Project Properties & MSBuild Macros
Why can't I use MSBuild macros in a C# Project's properties? 为什么我不能在C#项目的属性中使用MSBuild宏? These all work find in a CPP project.
所有这些工作都可以在CPP项目中找到。
For example: 例如:
I have the same problem with "Xml documentation file path" and other fields. 我对“ Xml文档文件路径”和其他字段有相同的问题。
Why can't I use MSBuild macros in a C# Project's properties?
为什么我不能在C#项目的属性中使用MSBuild宏? These all work find in a CPP project.
所有这些工作都可以在CPP项目中找到。
This is because the way C# and CPP project introduce macros is not the same. 这是因为C#和CPP项目引入宏的方式不同。
For C# project, it introduced by the .props
, .targets
files, for example, the Microsoft.CSharp.targets file. 对于C#项目,它是由
.props
和.targets
文件引入的,例如Microsoft.CSharp.targets文件。 In your project file .csproj
you will find following Import: 在项目文件
.csproj
您将找到以下导入:
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
For CPP project, it introduced by property sheets, you can get it from View
-> Other Windows
-> Property Manager
, which is not supported by C# project. 对于CPP项目,它是由属性表引入的,您可以从
View
> Other Windows
> Property Manager
获得它,而C#项目不支持。
The different: 不同之处:
You can use property sheets to create project configurations that can be applied to multiple projects since project settings that are defined in .vsprops files are inheritable , unlike project settings defined in Project Files (.vcproj files).
您可以使用属性表来创建可应用于多个项目的项目配置,因为.vsprops文件中定义的项目设置是可继承的 ,这与项目文件(.vcproj文件)中定义的项目设置不同。 Therefore, a project configuration defined in a .vcproj file can inherit project settings from one or more property sheets (.vsprops files) .
因此, .vcproj文件中定义的项目配置可以从一个或多个属性表(.vsprops文件)继承项目设置 。 For more information, see Property Inheritance.
有关更多信息,请参见属性继承。
That the reason why you can use MSBuild macros in a CPP Project's properties but not in C# project. 因此,您可以在CPP项目的属性中使用MSBuild宏,但不能在C#项目中使用MSBuild宏的原因。
You can check following document for some more details: 您可以检查以下文档以了解更多详细信息:
Common macros for build commands and properties 构建命令和属性的通用宏
Property Sheets (C++) 属性表(C ++)
Hope this helps. 希望这可以帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.