简体   繁体   中英

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

Recently I tried to import SignalR dlls into a Unity project (support for .NET Standard 2.0). The NuGet package -> Microsoft.AspNetCore.SignalR.Client is currently at version 3.1.2. Here are the dependencies listed:

.NETStandard,Version=v2.0

Microsoft.AspNetCore.Http.Connections.Client

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

However, when I move these dlls into the Unity project, I'm greeted with an error:

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'

That makes sense to me, as I don't expect Unity to support Version 2.1 (the table at the .NET Standard docs states that 2.0 is the latest for Unity. I'm able to downgrade the package to Version 1.1, and everything works as expected (at least this error disappears). I determined which version of SignalR.Client to choose by going through each version, installing/copying until the errors disappeared.

The dependencies for 1.1.0 are identical (exception the Core and Client packages are now listed as (>=1.1.0) instead of (>= 3.1.2) .

Question: Is there a "better" way than guess-and-check to figure out which version of .NET Standard is required, maybe a spec somewhere that shows which version of .NET Standard needs to be supported for a package to be used?

Yes, there is an easy way.

FuGet lists many details about NuGet packages, including which versions of which frameworks are targeted. For example, Microsoft.AspNetCore.SignalR.Client 3.1.2 targets netstandard2.0.

A handy shortcut is you're looking at the NuGet page for a package, you can easily get to the Fuget page by just replaying "nuget" in the URL bar with "fuget".

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM