views:

428

answers:

1

We need to define a conditional compilation symbol in a class library project. This should not be checked in the source control (it doesn't apply to all developers), so it should be defined in someplace other than the .csproj or the app.config file. How can this be achieved?

+6  A: 

What I would do is define your various build types in the configuration manager (Build->Configuration Manager) and setup each of the required constants on each of the build types. You can then have each member of the team simply select the build type they want to do and it will automatically use the appropriate constants. (I think that the most recently used build type is stored in the .suo file, which is "solution user options" and you wouldn't normally check in to your source control, so this would be maintained specifically for each user).

You can define pre-processor constants on the c# compiler command line using the /define. switch. but you will have the problem of how to call this. Any changes you make to the project properties to use this will be saved to the csproj file. You would have to do all of your building from the command line instead which I'm sure you won't want. You can also define them in msbuild scripts, but you would have the same problem.

Simon P Stevens