除了csproj中的现有定义之外,还定义了常量

时间:2016-04-22 12:09:27

标签: csproj

好像我有一个如下所示的csproj文件,我最终定义了BAR并且没有定义FOO。

<PropertyGroup>
  <DefineConstants>FOO</DefineConstants>
</PropertyGroup>
<PropertyGroup>
  <DefineConstants>BAR</DefineConstants>
</PropertyGroup>

是否有“定义附加常量”的语法,以便我可以使用它并最终定义FOO和BAR?

我知道在这个人为的例子中,我可以拥有

<PropertyGroup>
  <DefineConstants>FOO BAR</DefineConstants>
</PropertyGroup>

但我的实际用例更复杂。除了之前设置的内容之外,我真的需要能够定义一个常量。

1 个答案:

答案 0 :(得分:4)

这样做:

<PropertyGroup>
  <DefineConstants>FOO</DefineConstants>
</PropertyGroup>
<PropertyGroup>
  <DefineConstants>$(DefineConstants);BAR</DefineConstants>
</PropertyGroup>