I have a project with a preprocessor constant defined for a configuration
<DefineConstants>TRACE;DEBUG;VAR1</DefineConstants>
My code could be :
#if VAR1
Console.WriteLine("Var1");
#endif
#if VAR2
Console.WriteLine("Var2");
#endif
I want execute MSBuild and define the constant VAR2 without override constants defined in the configuration
I try :
MSBuild MyProject.csproj /p:DefineConstants=VAR2
But constants defined in the project file are not set : my program displays only
Var2
I have tried things like without success :
MSBuild MyProject.csproj /p:DefineConstants=$(DefineConstants);VAR2
or
<DefineConstants>$(DefineConstants);TRACE;DEBUG;VAR1</DefineConstants>
Is it a way to merge the constants defined in the project and constants defined on the command line?