title: Conditional inclusion of projects in Visual Studio solution files
body: <p>I am developing a set of interdependent libraries, and I would like to generate several versions of these libraries, targetted at different .NET framework versions. Sure enough, this is a common issue and there is plenty of documentation available on how to write <code>.csproj</code> files in such a way that either the (more frequently mentioned) <code>configuration</code> or the (IMHO much better suited) <code>platform</code> variable includes a choice for the target framework.</p>
  
  <p>All of the libraries are in a common solution.</p>
  
  <p>Now, some of the libraries have external dependencies that are only available on newer .NET framework versions. Hence, for the older versions, building the respective projects makes no sense.</p>
  
  <p><strong>How can I exclude some of the projects based upon the selected <code>platform</code>?</strong></p>
  
  <p>I imagine the answer to this problem must be one of these ways, but I could not find any concrete information on how to do this:</p>
  
  <ul>
  <li>Either, it must be a setting in the <code>.sln</code> file that allows me to conditionally exclude some of the projects from the solution. From the <a href="https://msdn.microsoft.com/en-us/library/bb165951.aspx" rel="nofollow">MSDN docs</a>, it doesn't get clear to me whether any of the projects in the <code>.sln</code> file can be marked to be built only when a given set of settings is active.</li>
  <li>Or, it might be a setting in the <code>.csproj</code> file that allows me to conditionally disable compilation (not making compilation fail, rather indicating the project should not currently be built). My first guess was the <a href="https://msdn.microsoft.com/de-de/library/bb629394.aspx" rel="nofollow"><code>OutputType</code> setting</a>, but it only allows <code>Library</code>, <code>Exe</code>, <code>Module</code>, and <code>Winexe</code>; there is no value such as <code>None</code>.</li>
  </ul>
  
  <p>Of course, there is the workaround of creating a separate <code>.sln</code> file per .NET framework version, but this sounds cumbersome (and hence error-prone), given that any future additional library would have to be added to each of the <code>.sln</code> files, so there would be a lot of duplication of solution code and a lot of duplicate effort.</p>
  
  <p><em>I prefer learning how to do this in the source code of <code>.sln</code> and/or <code>.csproj</code> files.</em></p>