We’re using Hudson and msbuild.exe to build C# software, and I know it’s possible to define (effectivly boolean) compilation symbols (as DEBUG or SOMETHING). I would like to have a value in my code that is defined while compiling the project, imagine an affiliate string or a personalised key or something like this. Something that can be used in the C# code.
Is this really not possible? If it isn’t possible with compilation symbols, how would you approach this problem? Or is this so obvious that I just didn’t see it?
It is not possible to add a string to the compilation symbols in C# and there is no equivalent of C(++)’s #define.
The best thing to do is to add a file to your project that has a single constant defined in it. During compilation update the file to have the value you want. You can do this using the WriteLinesToFile task in MSBuild.