For user authorization, I only want to include a specific module for each user. So I configured Conditional Compilation like this
<DefineConstants>TRACE;DEBUG;SAMPLECONSTANT1</DefineConstants>
and edited the project file like this:
<ProjectReference Include="..\Solution1.Modules.Module1\Solution1.Modules.Module1.csproj" Condition="$(DefineConstants.Contains('SAMPLECONSTANT1'))">
<Project>{4E378BD0-4FF8-4160-9331-1ECBFD2B6F30}</Project>
<Name>Solution1.Modules.Module1</Name>
</ProjectReference>
For this case I want to add reference to project Module1
if DefineConstants
contains SAMPLECONSTANT1
; but no matter what I put in DefineConstants
, the solution always loads the Module1
project. What did I do wrong here?
UPDATE: Actually my code is correct. Please see J0e3gan's answer. Visual Studio UI does not reflect conditional references within the References
folder of a project. Therefore all references are visible in any given configuration or platform selection. The compiler and IntelliSense on the other hand are aware of conditional references, honoring the correct settings both with visual feedback and error notification during builds.