Reputation: 3005
I have C# project that has to target .NET 3.5. framework and I have several nuget packages I'd like to install in the given project.
How to find out, for a given nuget package, which .NET framework versions it supports (by version of package for example), without me trying to install every available version of the package in order to see if its installation will pass without rolling back because of the dependency of the given version of the package to .NET framework higher than 3.5.?
For example, I know that xUnit.net version 1.9.2. is the highest version that supports .NET 3.5, but I had to find out this "manually".
Upvotes: 51
Views: 13859
Reputation: 1063
The Nuget package Metadata has a list of Dependencies per Framework. This can be used to determine the supported target frameworks, but is not 100% reliable.
The Nuget package (which is a .zip file with file extension .nupkg) usually has a "lib" folder which contains a subfolder for each target framework. The names for the subfolders are not identical with the name of the target framework.
Example: "20" means ".Net 2.0", "SL" means "Silverlight", "net6.0" means ".Net 6.0", etc.
So, in order to get the supported target frameworks of a nuget package, it could be done by downloading it and examining the .nupkg file as .zip file.
Upvotes: 0
Reputation: 139
As of June 2022 there's at last the possibility to see which .NET Framework/Standard version is supported by a package.
Unfortunately it's only on the website and does not work in Visual Studio. Nevertheless it's very practical.
Here's how it looks for Newtonsoft.Json 13.0.2:
This is far from what I deemed as necessary, but it's a beginning (after 6 years of waiting).
Upvotes: 0
Reputation: 464
At the risk of upsetting the Stack admins for daring to submit a wrong answer... You can download the .nupkg file (https://www.nuget.org/packages > Download ) then unzip it. In the file you can find references to PlatformToolset, ToolsVersion which I was able to use to look up the specific version of the compiler. ("v110" = Visual C++ 2012, "v120" = Visual C++ 2013, etc. To get the framework you could use decompiler a tool like ILSpy to inspect included files to see what version they target.
Upvotes: 0
Reputation: 41
Cannot comment on the previous answer, but the targetFramework attribute in packages.config is the .NET version of the project at the time that package was installed.
For example, I have two projects that use Newtonsoft.Json 9.0.1, and these are the lines in their respective packages.config files:
<package id="Newtonsoft.Json" version="9.0.1" targetFramework="net452" />
and
<package id="Newtonsoft.Json" version="9.0.1" targetFramework="net462" />
Upvotes: 4
Reputation: 53
packages.config should give you the version info
example
<package id="xunit" version="2.2.0-beta1-build3239" targetFramework="net46" />
<package id="xunit.abstractions" version="2.0.0" targetFramework="net46" />
<package id="xunit.assert" version="2.2.0-beta1-build3239" targetFramework="net46" />
<package id="xunit.core" version="2.2.0-beta1-build3239" targetFramework="net46" />
<package id="xunit.extensibility.core" version="2.2.0-beta1-build3239" targetFramework="net46" />
<package id="xunit.extensibility.execution" version="2.2.0-beta1-build3239" targetFramework="net46" />
<package id="xunit.runner.msbuild" version="2.2.0-beta1-build3239" targetFramework="net46" developmentDependency="true" />
<package id="xunit.runner.visualstudio" version="2.2.0-beta1-build1144" targetFramework="net46" developmentDependency="true" />
Upvotes: 1