c++visual-studiomsbuild

MSBuild: set a specific preprocessor #define in the command line


In a C++ file, I have code like this:

#if ACTIVATE
#    pragma message( "Activated" )
#else
#    pragma message( "Not Activated")
#endif

I want to set this ACTIVE define to 1 with the MSBuild command line.

It tried this, but it doesn't work:

msbuild /p:DefineConstants="ACTIVATE=1"

How can I do it?


Solution

  • The answer to ponder is: you cannot