title: Build .NET project dependency by condition
body: <p>I have one main project and several dependecies in my solution. I want my main project has only one reference to dependent project by condition (compilation symbol).</p>
  
  <p>I tryed to add this code to project file for each dependend project:</p>
  
  <pre><code>&lt;ItemGroup Condition="$(DefineConstants.Contains('SomeConstant'))"&gt;
    &lt;ProjectReference Include="..\DependentProj1\DependentProj1.csproj"&gt;
      &lt;Project&gt;{7d971fa6-9225-4d54-b21c-077eb46c5dd4}&lt;/Project&gt;
      &lt;Name&gt;DependentProj1&lt;/Name&gt;
    &lt;/ProjectReference&gt;
  &lt;/ItemGroup&gt;
  </code></pre>
  
  <p>In this case all dependend projects are built and only one binary file is copied to main output. It doesn't suit me.</p>
  
  <p>I also tryed:</p>
  
  <pre><code>&lt;Choose&gt;
    &lt;When Condition="$(DefineConstants.Contains('SomeConstant'))"&gt;
      ...
    &lt;/When&gt;
  &lt;/Choose&gt;
  </code></pre>
  
  <p>But for some reasons it didn't work as I want.</p>
  
  <p>Can anybody advise me how to build ONLY ONE dependency when I change conditional compilation symbol?</p>
  
  <p>Thank you!</p>