title: System.Net.Http in net47
body: <p>I have a normal class library on Windows, using .NET 4.7</p>
  <p>I would like to include <a href="https://github.com/web-push-libs/web-push-csharp" rel="nofollow noreferrer">web-push-csharp</a>.</p>
  <p>The package lists 2 acceptable dependencies (Newtonsoft Json and BouncyCastle). It also wants to install <a href="https://www.nuget.org/packages/Microsoft.Net.Http/" rel="nofollow noreferrer">Microsoft.Net.Http</a>. And I have no idea why. I don't need it. My target framework comes with a perfectly fine <code>System.Net.Http</code> to reference. <strong>As that Microsoft package has a list of other dependencies that clash with other dependencies higher up in my chain, this is a huge inconvenience. Why would I include a package I don't need?</strong></p>
  <p>Now I thought that that should not be a problem, went and cloned the web push package repository, to put my target framework in and... it's correct, you cannot compile for target framework <code>net47</code> without an outside <code>*.Net.Http</code> reference. Yet my <code>Create New Project</code> .NET 4.7 project already comes with such a reference without touching nuget at all.</p>
  <p>Copying all the packages files into a new ClassLibrary1 works great with just NewtonsoftJson and BouncyCastle.</p>
  <p>What am I missing here? Why did the .NET Framework lose it's System.Net.Http from 4.5 to 4.6? And why is there no FrameworkTarget available where I can say &quot;this is fine, I have a full 4.7&quot;?</p>
  <p>Is there another option aside from just cloning the repository and creating a normal 4.7 class library from it for my use?</p>
  <hr />
  <p>Additional information:</p>
  <p>I cloned the web-push-csharp repository and added a new target framework <code>net47</code> without any dependency on <code>Microsoft.Net.Http</code>:</p>
  <pre><code>&lt;Project Sdk=&quot;Microsoft.NET.Sdk&quot;&gt;
    &lt;PropertyGroup&gt;
      &lt;TargetFrameworks&gt;netcoreapp1.0;netcoreapp1.1;netstandard1.3;net45;net46;net47&lt;/TargetFrameworks&gt;
    &lt;/PropertyGroup&gt;
  
    &lt;ItemGroup Condition=&quot;'$(TargetFramework)'=='net45' OR '$(TargetFramework)'=='net46'&quot;&gt;
      &lt;PackageReference Include=&quot;BouncyCastle&quot; Version=&quot;1.8.1&quot; /&gt; 
      &lt;PackageReference Include=&quot;Microsoft.Net.Http&quot; Version=&quot;2.2.29&quot; /&gt;
    &lt;/ItemGroup&gt;
  
    &lt;ItemGroup Condition=&quot;'$(TargetFramework)'=='net47'&quot;&gt;
      &lt;PackageReference Include=&quot;BouncyCastle&quot; Version=&quot;1.8.1&quot; /&gt;
    &lt;/ItemGroup&gt;
  
    &lt;ItemGroup Condition=&quot;'$(TargetFramework)'=='netcoreapp1.0' OR '$(TargetFramework)'=='netcoreapp1.1' OR '$(TargetFramework)'=='netstandard1.3'&quot;&gt;
      &lt;PackageReference Include=&quot;BouncyCastle.NetCore&quot; Version=&quot;1.8.1.3&quot; /&gt; 
    &lt;/ItemGroup&gt;
  
    &lt;ItemGroup&gt;
      &lt;PackageReference Include=&quot;Newtonsoft.Json&quot; Version=&quot;10.0.3&quot; /&gt;
    &lt;/ItemGroup&gt;
  &lt;/Project&gt;
  </code></pre>
  <p>That lead to multiple compile errors along the line of:</p>
  <blockquote>
  <p>Error  CS0234  The type or namespace name 'Http' does not exist in the namespace 'System.Net' (are you missing an assembly reference?) WebPush(net47)</p>
  </blockquote>
  <hr />
  <h1>Solution</h1>
  <p>For anyone reading this looking for a solution: After testing, I incorporated the <a href="https://stackoverflow.com/questions/46790546/system-net-http-in-net47/46791790#46791790">accepted answer</a> into a <a href="https://github.com/nielsvoigt/web-push-csharp/tree/SystemHttp" rel="nofollow noreferrer">branch</a> of a fork and sent the maintainer a <a href="https://github.com/web-push-libs/web-push-csharp/pull/18" rel="nofollow noreferrer">Pull request</a> so it can be used in the original package.</p>