为什么 .netstandard 1.4 是 NetStandard.Library 1.6?

why .netstandard 1.4 is NetStandard.Library 1.6?

我创建了一个.net core class库包并上传到nuget.org

在依赖项部分说我的项目依赖于 .NetStandard 1.4,即 NetStandard.Library 高于 1.6

为什么版本号会出现如此混乱的不匹配? .NetStandard 和 NetStandard.Library 不应该是同一回事吗?或者它们是不同的东西?

这是我的 .csproj

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>netstandard1.4</TargetFramework>
    <PackageVersion>2.0.1</PackageVersion>
    <AssemblyName>currency</AssemblyName>
  </PropertyGroup>
</Project>

和 link 我的项目:

https://www.nuget.org/packages/currency/

我找到了一个关于 .NETStandard.Library 的有趣页面:

What is the .NETStandard.Library metapackage?

在此页面上,作者说了以下内容:

So even if your project is targeting .NET Standard version 1.3 (or multi-targeting), you can still use the latest NETStandard.Library package version (1.6.1 at the time of writing). The package itself is versioned primarily because it also contains various tooling support such as the list of .NET Standard versions.


在微软的文档中,我发现关于您的问题的信息如下:

It may seem strange to target netstandard1.3 but use the 1.6.0 version of NETStandard.Library. It is a valid use-case, since the metapackage maintains support for older netstandard versions. It could be the case you've standardized on the 1.6.0 version of the metapackage and use it for all your libraries, which target a variety of netstandard versions. With this approach, you only need to restore NETStandard.Library 1.6.0 and not earlier versions.

Link: Look at .NetStandard

我认为,它将永远使用最新版本的 .NETStandard.Library,因为它与旧版本的 .NETStandard 兼容,并且它只是一个带有引用和一组标准 .Net API 的元数据包.所以这应该不是问题,如果你的包使用 .NETStandard.Library 版本 1.6.1

注意:如果您使用.NETStandard 2.0 并且您使用.NETStandard.Library 版本1.6.1,则无法使用!


更新:就像svick在这个答案的评论中提到的那样,.NETStandard.Library的最低版本是1.6.0版!