[英]using compilation symbols(?) in custom build events VS2013
I am trying to make a build event and I want to know if it is possible to use symbols that you define with #define TEST. 我正在尝试进行构建事件,我想知道是否可以使用通过#define TEST定义的符号。
I am guessing it would have to be done using custom macros defined in the project file. 我猜想它必须使用项目文件中定义的自定义宏来完成。
Thank you for your help 谢谢您的帮助
It is not possible to directly import #define TEST
constructions from your *.cs files (ok, it's possible, but I think it doesn't worth it). 无法从* .cs文件中直接导入#define TEST
构造(好的,有可能,但是我认为这样做不值得)。
Instead, you can define build configuration (or use standard Debug and Release), and add properties to your *.csproj project file like this: 相反,您可以定义构建配置(或使用标准的Debug和Release),然后将属性添加到* .csproj项目文件中,如下所示:
<PropertyGroup Condition="'$(Configuration)' == 'Debug'">
<TestDefined>yes</TestDefined>
</PropertyGroup>
Thus, you define a constant for Debug
configuration. 因此,您可以为Debug
配置定义一个常量。 Then, you can use it in build event conditions like 然后,您可以在构建事件条件中使用它,例如
if ('$(TestDefined)' == 'yes') ...
Alternatively, you can define constants using visual editor for project properties from inside VS.Net, they are stored & initialized in similar way by VS.Net: 另外,您可以使用可视化编辑器为VS.Net内部的项目属性定义常量,VS.Net以类似的方式存储和初始化常量:
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
...
<DefineConstants>DEBUG;TRACE</DefineConstants>
...
</PropertyGroup>
They require more coding to parse, but it's easier to edit constants themselves. 它们需要更多的代码来解析,但是自己编辑常量更容易。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.