I have a C# Library Project. I have defined a Conditional Compilation Symbol: SHOULDWORK
But the problem is that this symbol is NOT being defined. I have no idea why.
This is not an asp.net project. I am using VS 2013. I have used Preprocessor Definitions extensively in c++ so it is nothing new to me. But I just can't figure out what the problem is.
I tried rebuilding, restarting VS but to no avail. I tried using the SHOULDWORK symbol on different source files in that same project but the symbol is not defined.
HELP!!!
Just as sidenote, the DEBUG symbol works as expected. It is defined for Debug builds and not defined for Release builds.
** EDIT
The symbol is correctly stored in the *.csproj file:
** SOLVED
The csproj had several PropertyGroup entries where DefineConstants was being defined. I manually added the symbols I needed to define to those PropertyGroups and then it worked. It seems the project file was edited manually in the past, which could have led to this. It will need to be cleaned up but at least for now I can move on.
If using properties panel doesn't work you can modify manually the project file.
Now you can modify the project. Find all the propertygroup you are interested in: if you want to add the conditional compilation symbols far all compilation types, you should add the symbol in every single PropertyGroup related to compilation. This is an example of a propertygroup for compilation:
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
Inside the group you'll find the tag <DefineConstants>
:
Add here your constant and reload the project. Sure, you can simply modify le prj outside vs, as a simple text file.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With