有没有办法确定 NuGet 包针对的是哪个版本的 .Netstandard?

Is there a way to determine which version of .Netstandard is targeted by a NuGet package?

最近我尝试将 SignalR dll 导入 Unity 项目(支持 .NET Standard 2.0)。 NuGet 包 -> Microsoft.AspNetCore.SignalR.Client 当前版本为 3.1.2。以下是列出的依赖项:

.NETStandard,Version=v2.0

Microsoft.AspNetCore.Http.Connections.Client

(>= 3.1.2) Microsoft.AspNetCore.SignalR.Client.Core (>= 3.1.2)

但是,当我将这些 dll 移动到 Unity 项目中时,出现错误:

Error CS1705 Assembly 'Microsoft.AspNetCore.SignalR.Client.Core' with identity 'Microsoft.AspNetCore.SignalR.Client.Core, Version=3.1.2.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' uses 'netstandard, Version=2.1.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' which has a higher version than referenced assembly 'netstandard' with identity 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'

这对我来说很有意义,因为我不希望 Unity 支持版本 2.1(.NET Standard docs 处的 table 声明 2.0 是 Unity 的最新版本。我能够将软件包降级到 1.1 版,一切都按预期工作(至少这个错误消失了)。我通过遍历每个版本来确定要选择 SignalR.Client 的哪个版本,installing/copying 直到错误消失。

1.1.0 的依赖项是相同的(除了核心和客户端包现在列为 (>=1.1.0) 而不是 (>= 3.1.2)

问题:是否有比猜测和检查“更好”的方法来确定需要哪个版本的 .NET Standard,也许某个地方的规范显示了哪个版本要使用的包需要支持 .NET Standard 吗?

是的,有一个简单的方法。

FuGet 列出了有关 NuGet 包的许多详细信息,包括针对哪些框架的哪些版本。例如,Microsoft.AspNetCore.SignalR.Client 3.1.2 以 netstandard2.0 为目标。

一个方便的快捷方式是您正在查看包的 NuGet 页面,只需在 URL 栏中使用 [=18= 重播 "nuget" 即可轻松进入 Fuget 页面].