title: How can I specify different dependencies for different versions of the .NET framework in a custom NuGet package?
body: <p>I'm trying to create a NuGet package which has a dependency on <code>System.Net.Http</code> (need the HttpClient). For framework version 4.5.1, this assembly is a part of the BCL. Hoewever, in 4.0 it is not. I believe it having compiling correctly with the proper conditional statements in the csproj. </p>
  
  <p>The problem I'm currently wrestling with is that when I reference this package in a 4.5.1 project, it pulls in the dependency on <code>Microsoft.Net.Http</code>. I really only want to depend on <code>Microsoft.Net.Http</code> for net40.</p>
  
  <p>Here's my nuspec file:</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;package&gt;
    &lt;metadata&gt;
      &lt;id&gt;MyApp&lt;/id&gt;
      &lt;version&gt;$version$&lt;/version&gt;
      &lt;title&gt;MyApp&lt;/title&gt;
      &lt;authors&gt;Me&lt;/authors&gt;
      &lt;owners&gt;Me&lt;/owners&gt;
      &lt;requireLicenseAcceptance&gt;false&lt;/requireLicenseAcceptance&gt;
      &lt;description&gt;Description&lt;/description&gt;
      &lt;releaseNotes&gt;Initial release&lt;/releaseNotes&gt;
      &lt;copyright&gt;Copyright 2016&lt;/copyright&gt;
      &lt;dependencies&gt;
        &lt;group&gt;
          &lt;dependency id="Newtonsoft.Json" version="8.0.2"/&gt;
        &lt;/group&gt;
        &lt;group targetFramework="net40"&gt;
          &lt;dependency id="Microsoft.Bcl" version="1.1.10" /&gt;
          &lt;dependency id="Microsoft.Bcl.Build" version="1.0.14" /&gt;
          &lt;dependency id="Microsoft.Net.Http" version="2.2.29" /&gt;
        &lt;/group&gt;
      &lt;/dependencies&gt;
    &lt;/metadata&gt;
    &lt;files&gt;
      &lt;file src="bin\release\**\MyApp.dll" target="lib" /&gt;
    &lt;/files&gt;
  &lt;/package&gt;
  </code></pre>
  
  <p>In VS, the NuGet package shows this:</p>
  
  <p><a href="https://i.stack.imgur.com/l78xz.png" rel="noreferrer"><img src="https://i.stack.imgur.com/l78xz.png" alt=".NETFrameworkVersion=v4.0"></a></p>
  
  <p>But again, I'm those dependencies are also being pulled in when using a project with target framework 4.5.1. Which I don't want. Any help is appreciated.</p>