我正在尝试将Microsoft.AspNet.WebApi
Nuget包添加到C#类库项目中。如果需要,这里是Project源代码。
当我在Visual Studio 2013的Nuget包管理器控制台中执行以下命令时(它具有最新的.NET 4.5)
PM> install-package Microsoft.AspNet.WebApi ErrandBoy.Web.Common
我收到以下错误。
PM> install-package Microsoft.AspNet.WebApi ErrandBoy.Web.Common
Attempting to resolve dependency 'Microsoft.AspNet.WebApi.WebHost (≥ 5.2.2 && < 5.3.0)'.
Attempting to resolve dependency 'Microsoft.AspNet.WebApi.Core (≥ 5.2.2 && < 5.3.0)'.
Attempting to resolve dependency 'Microsoft.AspNet.WebApi.Client (≥ 5.2.2)'.
Attempting to resolve dependency 'Newtonsoft.Json (≥ 6.0.4)'.
'Microsoft.AspNet.WebApi 5.2.2' already installed.
Adding 'Newtonsoft.Json 6.0.4' to ErrandBoy.Web.Common.
Successfully added 'Newtonsoft.Json 6.0.4' to ErrandBoy.Web.Common.
Adding 'Microsoft.AspNet.WebApi.Client 5.2.2' to ErrandBoy.Web.Common.
install-package : Failed to add reference to 'System.Net.Http'. Please make sure that it is in the Global Assembly Cache.
At line:1 char:1
+ install-package Microsoft.AspNet.WebApi ErrandBoy.Web.Common
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Install-Package], InvalidOperationException
+ FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PowerShell.Commands.InstallPackageCommand
具体的错误行如下。它似乎在尝试添加对添加的引用'Microsoft.AspNet.WebApi.Client 5.2.2'
Failed to add reference to 'System.Net.Http'. Please make sure that it is
in the Global Assembly Cache.
我从来没有犯过这样的错误。我确实在此SO Overflow问题上看到了类似的错误=>安装ASP.NET Identity 2示例时出错,但是没有答案。
我只是有同样的问题。我通过手动添加System.Net.Http
到引用中解决了它。然后它抱怨其他人,但是在手动将它们手动添加之后,我可以使用NuGet安装该软件包。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句