3

I've got an an assembly that targets netstandard 2.0 so that it can be used from .NET Core and full .NET Standard projects. I'm using the dotnet pack command to create a nuget package which is then being pushed into a local nuget host server (created by following the instructions found here.

Now, since netstandard base assemblies can be consumed from .NET 4.7.1 projects, I thought that I should be able to see nuget packages that target netstandard when I'm listing my local nuget packages from VS nuget package manager UI (and the project is being built against .NET 4.7.1). Unfortunately, the only way I've managed to get it to be shown was by changing the nuget.server settings so that it doesn't filter the returned results by framework version.

Is this the expected behavior? Shouldn't I be able to add references to nuget packages that have assemblies that target .net standard?

Luis

aydinugur
  • 1,208
  • 2
  • 14
  • 21
Luis Abreu
  • 4,008
  • 9
  • 34
  • 63

1 Answers1

0

If you look in the official .NET standard documentation you can see that .Net standard 2.0 is supported on .Net framework 4.6.1 and up but you need to have the relevant .Net core 2.0 SDK installed for it to work. Check the table in the documentation. You probably don't have it where you want to consume the package.

Another option is that you add also classic .NET Framework as and additional platform in your project. Then when you build the NuGet package it will contain also another dll for the classic .NET framework so it will always work. You add another target platform in the project by finding the following element <TargetFramework>netcoreapp2.0</TargetFramework> and then you can change it to include for example like that <TargetFrameworks>netcoreapp2.0;net461</TargetFrameworks> to include also .NET 4.6.1. More details about what values are valid for the target frameworks is in the documentation. Target Frameworks

Aleš Doganoc
  • 11,568
  • 24
  • 40
  • Hello. The machine I'm using has everything that's required. The question is more along the lines: why aren't packages with assemblies that target net standard 2 not shown when you're writing Net 4.7.1 projects? Thanks – Luis Abreu Dec 10 '17 at 18:31
  • For me they are shown normally. Try for example to search the package Microsoft.Extensions.Logging from nuget.org. The version 2.0 is also only .NET standard 2.0 and for me it is shown in a .NET 4.7 project. I have also tried to create my own package and set a local folder as the NuGet source and again I can add it without issues. Maybe it is a problem with the NuGet server you are using. Try what I did to set a local folder as the NuGet source. – Aleš Doganoc Dec 10 '17 at 18:55
  • Thanks again... Unfortunately, using a shared folder isn't an option because I need to integrate it with the external build system... – Luis Abreu Dec 10 '17 at 19:39
  • I did not mean to use this as a solution just to check if there is an issue with your package. If in this way you can install without problems then it is definitely an issue with the NuGet server you are using. If the NuGet server was created before .NET Core 2.0 it probably needs some upgrade to support it properly. – Aleš Doganoc Dec 10 '17 at 21:22
  • Yep, everything works fine when using the share. So, there might be a problem with the nuget.server package I'm using to create the server...thanks again – Luis Abreu Dec 10 '17 at 22:01
  • Just to let you guys know that I've managed to get some feedback from ms. this is "known" issue and that it hasn't been solved yet. BTW, Nuget gallery is not performing any filtering either... – Luis Abreu Dec 12 '17 at 20:22