Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DefineConstants in addition to existing ones in csproj

Tags:

msbuild

csproj

It seems like if I have a csproj file like the following, I end up with BAR defined and FOO not defined.

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

Is there a syntax for "Define additional constants" so that I can use it and end up with both FOO and BAR defined?

I am aware that in this contrived example, I could just have

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

But my actual use case is more complicated. I really need to be able to define a constant in addition to whatever was set before.

like image 831
William Jockusch Avatar asked Apr 22 '16 12:04

William Jockusch


1 Answers

This does it:

<PropertyGroup>
  <DefineConstants>FOO</DefineConstants>
</PropertyGroup>
<PropertyGroup>
  <DefineConstants>$(DefineConstants);BAR</DefineConstants>
</PropertyGroup>
like image 161
William Jockusch Avatar answered Oct 15 '22 23:10

William Jockusch