7

I have a home grown nuget package that targets netstandard1.6 published to a private feed. When I try to install it into a package that targets .NET Framework 4.6.2, nuget tells me:

You are trying to install this package into a project that targets '.NETFramework,Version=v4.6.2', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.

The dependency list for the package looks like:

enter image description here

I'm using Visual Studio 2017, March 28 2017 release.

I thought this was the whole point of the .NET Standard library? What am I missing?

Athari
  • 33,702
  • 16
  • 105
  • 146
Chris
  • 27,596
  • 25
  • 124
  • 225

1 Answers1

7

The plan is that this will work with netstandard2.0 tooling, I believe - but it doesn't work at the moment due to some oddities around net46x.

There are two docs for the mappings between netstandard and .NET framework versions:

As you can see, in "current", only "vNext" supports netstandard1.6. You should be okay targeting a netstandard1.5 library from .NET 4.6.2 though - do you actually need your package to target netstandard1.6? (There's not a lot in 1.6 that's not in 1.5.)

Jon Skeet
  • 1,421,763
  • 867
  • 9,128
  • 9,194
  • I'm also working with a new ASP.NET Core 1.1 project, and my understanding was that Core 1.1 requried .NET Standard 1.6. – Chris Mar 30 '17 at 06:38
  • @Chris: It's not clear what you mean. You can *consume* a library that supports (say) netstandard1.3 from ASP.NET Core 1.x. (It's also worth being clear between ASP.NET Core and .NET Core - it's not clear what you mean by "Core 1.1" in this case.) If you make your library target netstandard1.5 or lower, you should be fine. – Jon Skeet Mar 30 '17 at 06:44
  • I meant .NET Core 1.1. I think I was thinking backwards and what you said makes sense. I'll try targeting .NET Standard 1.5 and see if it works. – Chris Mar 30 '17 at 06:54
  • So I tried updating the library to target .NET 1.5 and publishing an updated package. The error remains. However, I am able to get the package to install if I update the library's .csproj by changing `netstandard1.5` to `net462;netstandard1.5` as recommended by someone else. Seems like a tooling/documentation oversight somewhere. – Chris Mar 30 '17 at 07:08
  • @Chris: Hmm... that's very strange. I would really have expected that to work. Will try to look into it later on, but I can't right now. – Jon Skeet Mar 30 '17 at 07:43
  • @Chris I ran into this as well and you suggestion resolved it for me. NuGet does not understand the compatibility matrix of .NET Standard against .NET Framework, so explicitly pointing out targets in the resource's csproj provides a hint. I don't believe this is a failing of the tooling. NET Standard 2.0 exposes the same APIs as 4.6.1, plus about 43 additional to maintain backward compat with net standard 1.6. It's possible that a library author may want to advertise .NET Standard 2.0, but not imply .NET Framework 4.6.1 portability. – Matthew May 22 '17 at 17:56
  • Reference: https://github.com/dotnet/standard/tree/master/docs/netstandard-20#net-framework-461-supporting-net-standard-20 – Matthew May 22 '17 at 17:57
  • .NET Standard Chart: https://github.com/dotnet/standard/blob/master/docs/versions.md – M.Hassan Sep 19 '18 at 20:13