In a C++ file, I have a code like this:
#if ACTIVATE
# pragma message( \"Activated\" )
#else
# pragma message( \"Not Activated\")
#endif
I
C++ projects (and solutions) are not (yet ?) integrated in the MSBuild environment. As part of the build process, the VCBuild task is called, which is just a wrapper around vcbuild.exe.
You could :
ACTIVATE=1
would be defined, and compile it with devenv.exe (with the /ProjectConfig switch).Note that your solution would not work for C# projects either unless you tweaked your project files a bit. For reference, here is how I would do this :
:$(DefineConstants);$(MyConstants)
msbuild /p:MyConstants="ACTIVATE=1"