views:

20

answers:

2

For C++ projects I can do this:

SET CL=/DMYDIRECTIVE
devenv.exe MySolution.sln /rebuild

What is the C# version (visual studio 2008) of this trick?

+2  A: 

Go to the Build tab in Project Properties

On the command line, csc /define:MYDIRECTIVE

SLaks
+1  A: 

The following command lists you the options of the C# compiler

csc.exe /?

The respective option is

/define:<symbol list>   Define conditional compilation symbol(s) (Short form: /d)

However, for command-line building a C# project you might prefer MSBuild. With MSBuild, it is probably easiest to create a configuration using Visual Studio's Configuration Manager that already defines appropriate conditional compilation symbols. You can then select one of the configurations from the MSBuild command line:

MSBuild MySolution.sln /t:Rebuild /p:Configuration=ReleaseWithMyDirective
0xA3