gpt4 book ai didi

c# - 为什么.netstandard 1.4 是 NetStandard.Library 1.6?

转载 作者:太空狗 更新时间:2023-10-29 20:19:29 24 4
gpt4 key购买 nike

我创建了一个.net核心类库包并上传到nuget.org

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

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

这是我的.csproj

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

以及指向我的项目的链接:

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.

链接: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 版!

关于c# - 为什么.netstandard 1.4 是 NetStandard.Library 1.6?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44711570/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com