[英]Is there a way to specify .NET Framework Version argument while using Install-Package in Nuget?
我們正在嘗試在面向.NET Framework 4.0
的項目中安裝Microsoft.AspNet.WebApi.Client
。 不幸的是,我們正在處理的服務器不支持.NET Framework 4.5。
使用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.
我們如何選擇合適的.NET框架是否存在命令行參數,我們可以提到.NET版本?
謝謝,
您無法選擇.NET版本,但您可以選擇NuGet包的版本:
PM> Install-Package Microsoft.AspNet.WebApi.Client -Version <package version>
所以你需要做的是弄清楚哪個版本是支持.NET 4.0的最新版本。 IIRC,這是4.0.30506 。
因此,要安裝版本4.0.30506,請使用該命令
PM> Install-Package Microsoft.AspNet.WebApi.Client -Version 4.0.30506
一些NuGet包可以包含各種不同.NET版本的構建(例如.NET 3.5,.NET 4,.NET 4.5等),但ASP.NET Web API 2僅支持.NET 4.5。
另一方面,ASP.NET Web API版本4.0.30506對應於ASP.NET Web API 1 ,它在.NET 4.0上運行。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.