I have a normal class library on Windows, using .NET 4.7
I would like to include web-push-csharp.
The package lists 2 acceptable dependencies (Newtonsoft Json and BouncyCastle). It also wants to install Microsoft.Net.Http. And I have no idea why. I don't need it. My target framework comes with a perfectly fine System.Net.Http to reference. 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?
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 net47 without an outside *.Net.Http reference. Yet my Create New Project .NET 4.7 project already comes with such a reference without touching nuget at all.
Copying all the packages files into a new ClassLibrary1 works great with just NewtonsoftJson and BouncyCastle.
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 "this is fine, I have a full 4.7"?
Is there another option aside from just cloning the repository and creating a normal 4.7 class library from it for my use?
Additional information:
I cloned the web-push-csharp repository and added a new target framework net47 without any dependency on Microsoft.Net.Http:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netcoreapp1.0;netcoreapp1.1;netstandard1.3;net45;net46;net47</TargetFrameworks>
</PropertyGroup>
<ItemGroup Condition="'$(TargetFramework)'=='net45' OR '$(TargetFramework)'=='net46'">
<PackageReference Include="BouncyCastle" Version="1.8.1" />
<PackageReference Include="Microsoft.Net.Http" Version="2.2.29" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)'=='net47'">
<PackageReference Include="BouncyCastle" Version="1.8.1" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)'=='netcoreapp1.0' OR '$(TargetFramework)'=='netcoreapp1.1' OR '$(TargetFramework)'=='netstandard1.3'">
<PackageReference Include="BouncyCastle.NetCore" Version="1.8.1.3" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="10.0.3" />
</ItemGroup>
</Project>
That lead to multiple compile errors along the line of:
Error CS0234 The type or namespace name 'Http' does not exist in the namespace 'System.Net' (are you missing an assembly reference?) WebPush(net47)
Solution
For anyone reading this looking for a solution: After testing, I incorporated the accepted answer into a branch of a fork and sent the maintainer a Pull request so it can be used in the original package.
PackageReference, add<Reference Include="System.Net.Http" />(regular, non-nuget reference) and it will compile for both 4.5\6 and 4.7.