I have a NuGet package (let's call it B) that references another NuGet package (let's call it A). Package B targets .NET Standard 2.0. NuGet Package A targets .NET Framework, .NET Standard 2.0, and .NET Standard 2.1.
When B is consumed by a .NET 5 application (let's call it C), it always chooses the .NET Framework version of A. This produces
NU1701 warning: was restored using '.NETFramework,Version=v4.6.1, .NETFramework,Version=v4.6.2, .NETFramework,Version=v4.7, .NETFramework,Version=v4.7.1, .NETFramework,Version=v4.7.2, .NETFramework,Version=v4.8' instead of the project target framework 'net5.0'. This package may not be fully compatible with your project.
Why would .NET 5 choose the .NET Framework version instead of one of the .NET Standard versions? This has to be a bug? It must see the other assemblies there and realize that this wouldn't be a warning?
I know I can force a sensible choice in application C by setting the HintPath to the exact lib location of A's assembly. Can I force proper behavior in Package B somehow?
C Project file looks like this:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>
<Platforms>anycpu</Platforms>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="B" Version="1.0.0.1" />
</ItemGroup>
</Project>
B's NuSpec file has:
<dependency id="A" version="2.2.1" />
Here's my NuGet package repository for A. It has an assembly in each folder. I would like .NET Standard 2.0 to avoid warning.
