In my C# file I want to have a preprocessor condition like this:
#if DEMO
ShowSplash();
#endif
I'm running this command from command line:
MSBuild MySolution.sln /p:Configuration=Release /p:Platform="Any CPU" /p:DEMO=1
Then, in MyProject.csproj file I have the following:
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DefineConstants>TRACE;DEMO=$(DEMO)</DefineConstants>
</PropertyGroup>
But the preprocessor seems to skip my splash code. (I'm aware of the difference between "Any CPU" and "AnyCPU". I never touched that, so I'm quite sure Visual Studio doesn't care about the space.)
DEMO is not defined? The same construct seems to work in other project types (e.g. .wixproj) What am I missing here?
.csproj?warning MSB3052: The parameter to the compiler is invalid, '/define:DEMO=1'<DefineConstants>TRACE</DefineConstants> <DefineConstants Condition=" $(DEMO) == 1 ">$(DefineConstants);DEMO</DefineConstants>MSBuild MySolution.sln /p:Configuration=Release /p:Platform="Any CPU" /p:Conditionals=DEMO. In your project you would then use<DefineConstants>TRACE;$(Conditionals)</DefineConstants>. (might or might not work; i have not tested it...)#if X=1. Put that stuff in an answer and I'll accept.