Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.NET Standard 2.0 NuGet Package Generation

I am working with my .NET class library project that targets Multiple .NET frameworks and now after having downloaded the .NET Core 2.0 SDK in my Windows 10 machine I am trying to target .NET Standard 2.0 as well.

<TargetFrameworks>net45;net46;netstandard1.0;netstandard1.3;netstandard2.0</TargetFrameworks>

The problem is that when the NuGet package generated by Visual Studio (2017) after compilation is opened via NuGet Package Explorer it shows that for .NET Standard 2.0 there are no dependencies.

Screenshot1Screenshot2

Shouldn't it be having NETStandard.Library 2.0.0 as a dependency?

If so is it necessary (at-least till an update is released for VS) that a dependency is explicitly specified in the NuGet package for NETStandard.Library 2.0.0?

To be certain that it wasn't an isolated case with my project I created another project and added Newtonsoft.Json as a dependency. The result was still the same.

Screenshot3

like image 896
Nathan Avatar asked Aug 28 '17 10:08

Nathan


1 Answers

The default NETStandard.Library version is still 1.6.1 when publishing for .NET Standard versions lower than 2.0. While the 2.0.0 version is technically the same (it has the same list of dependencies for the older .NET Standard versions), you risk creating downgrade warnings for consuming projects that reference version 1.6.1.

For .NET Standard versions 2.0 and higher, no dependency on NETStandard.Library is needed so your library will show "No Dependencies" as long as you don't add any additional NuGet packages.

like image 187
Martin Ullrich Avatar answered Nov 01 '22 07:11

Martin Ullrich