15

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.

abatishchev
  • 98,240
  • 88
  • 296
  • 433
William Jockusch
  • 26,513
  • 49
  • 182
  • 323

1 Answers1

34

This does it:

<PropertyGroup>
  <DefineConstants>FOO</DefineConstants>
</PropertyGroup>
<PropertyGroup>
  <DefineConstants>$(DefineConstants);BAR</DefineConstants>
</PropertyGroup>
William Jockusch
  • 26,513
  • 49
  • 182
  • 323