[英]Is there a way to specify .NET Framework Version argument while using Install-Package in Nuget?
We are trying to install Microsoft.AspNet.WebApi.Client
in a project that's targeting .NET Framework 4.0
. 我们正在尝试在面向
.NET Framework 4.0
的项目中安装Microsoft.AspNet.WebApi.Client
。 Unfortunately the servers we are working on don't support .NET Framework 4.5. 不幸的是,我们正在处理的服务器不支持.NET Framework 4.5。
When using Nuget Package Manager Console
with the Install-Package
command we are receiving the following error, 使用Nuget
Package Manager Console
和Install-Package
命令时,我们收到以下错误,
PM> install-package Microsoft.AspNet.WebApi.Client
Installing 'Microsoft.AspNet.WebApi.Client 5.1.1'.
.
.
.
Install-Package : Could not install package 'Microsoft.AspNet.WebApi.Client 5.1.1'. You are trying to install this package into a project that targets '.NETFramework,Version=v4.0', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.
How do we choose the right .NET framework is there a command-line argument where we can mention the .NET version? 我们如何选择合适的.NET框架是否存在命令行参数,我们可以提到.NET版本?
Thanks, 谢谢,
You can't select the .NET version, but you can select the version of the NuGet package: 您无法选择.NET版本,但您可以选择NuGet包的版本:
PM> Install-Package Microsoft.AspNet.WebApi.Client -Version <package version>
So what you'd need to do is to figure out which version was the latest version that supported .NET 4.0. 所以你需要做的是弄清楚哪个版本是支持.NET 4.0的最新版本。 IIRC, it was 4.0.30506 .
IIRC,这是4.0.30506 。
So, to install version 4.0.30506, you use the command 因此,要安装版本4.0.30506,请使用该命令
PM> Install-Package Microsoft.AspNet.WebApi.Client -Version 4.0.30506
Some NuGet packages can contain builds for various different .NET versions (eg .NET 3.5, .NET 4, .NET 4.5, etc.), but ASP.NET Web API 2 only supports .NET 4.5. 一些NuGet包可以包含各种不同.NET版本的构建(例如.NET 3.5,.NET 4,.NET 4.5等),但ASP.NET Web API 2仅支持.NET 4.5。
ASP.NET Web API version 4.0.30506, on the other hand, corresponds to ASP.NET Web API 1 , and IIRC it runs on .NET 4.0. 另一方面,ASP.NET Web API版本4.0.30506对应于ASP.NET Web API 1 ,它在.NET 4.0上运行。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.