如何让MSbuild只使用其中一个" DefineConstants"进行条件测试?

时间:2016-11-12 19:03:30

标签: compilation msbuild include conditional-statements

我在C#项目中有Condtional编译符号,定义为" ABC; XYZ",我可以在项目XML文件中使用以下内容,在MSBuild期间有条件地包含项目代码文件:

<Compile Include="SomeFile.cs" Condition="$(DefineConstants)'=='ABC;XYZ'"/>

但是我需要类似以下的东西:

<Compile Include="SomeFile.cs" Condition="$(DefineConstants)'=='ABC'"/>

是否可以只使用其中一个defineconstants进行条件测试?

1 个答案:

答案 0 :(得分:2)

我明白了...... this link帮助了。

基本上你只需要查看字符串,看它是否包含你想要根据你的条件确定的标签。就我而言,这是它的代码:

<Compile Include="SomeFile.cs" Condition="$(DefineConstants.Contains('ABC'))" />