Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Define a preprocessor value from command line using MSBuild [duplicate]

Tags:

I need to create a demo version of an existing large application consisting of multiple projects. I'd like to use the existing projects, and just neuter the functionality via preprocessor directives

#if DEMO     mycode.NeuterNow(); #endif 

We are building our app using MSBuild, and I'd ideally use something along the lines of:

MSBuild -DefineProperty:DEMO MySolution.sln 

Does such functionality exist?

like image 652
BrianH Avatar asked Jan 27 '09 21:01

BrianH


2 Answers

Try

msbuild /p:DefineConstants=DEBUG;DEMO MySolution.sln 

You have to include DEBUG or RELEASE and any other constants already defined in the solution file, but I think this should work. Disclaimer: I've never actually tried it myself.

like image 166
configurator Avatar answered Sep 29 '22 04:09

configurator


That's a duplicate of this one, and yes, /p:DefineConstants does work fine, and configurator is right, this will override ALL conditional symbols already defined in the Project File (which is good IMHO), so you'll have to define them all.

like image 32
2 revs Avatar answered Sep 29 '22 06:09

2 revs