- I am writing C# code using Jetbrains Rider.
- I would like to compile different behaviours depending on certain circumstances (as specified by my preprocessor constant). The idea is to have code such as this
#if MYCONSTANT
CallAGivenFunction();
#else
CallAnotherFunction();
#endif
So, if I want the first branch to be compiled (and seen by the Intellisense), I will define a preprocessor constant called MYCONSTANT; otherwise (by doing nothing), I will have the second branch be compiled.
Looking through the documentation I understood that I should create a file named Directory.build.props in the same folder as my .csproj, and that file should have
<Project>
<PropertyGroup>
<DefineConstants>MYCONSTANT</DefineConstants>
</PropertyGroup>
</Project>
However after doing that, the code in the #if clause CallAGivenFunction();
is still greyed out (i.e. Rider does not recognize the preprocessor constant I have defined).
What am I doing wrong?