views:

661

answers:

2

I want to use a compilation symbol, like DEBUG, except a different name, and have it associated with a solution, not a project, so that it applies to all the solution's projects.

Rather than define the same symbol in multiple projects, is there a way to define a symbol once, that applies solution-wide, via VS2008?

+1  A: 

One option you could use is to create a .cs file in 1 location with #define MYSYMBOL in it and add the file to each project in your solution using the Add as link option. This would allow you to have a single point of symbol/shared information definition.

Simon Wilson
This does not work in C#, because (from MSDN):The symbol remains defined until an #undef directive for that same symbol is processed, or until the end of the source file is reached. An implication of this is that #define and #undef directives in one source file have no effect on other source files in the same program.
Rene Schulte
A: 

You can define own Build configurations with the Visual Studio Configuration Manager and define the symbol in the project build configuration. It's easy and also works for C# (see my comment on Simon Wilson's answer). To do so, just click on in the Solution Configuration Manager and check "Create new project configurations". Then you can define the symbols in each project for the new build configuration.

Rene Schulte