本文介绍了由于提到的版本不再可用,因此无法还原/删除/更新NuGet软件包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试给 SignalR Sample 进行测试,但它似乎引用了旧的版本的SignalR不再可用.实际的问题是,NuGet必须先还原它才能删除不可用的程序包!!!

I'm trying to give the SignalR Sample a test drive but it seems it references an old version of SignalR which is no longer available. The actual problem is that NuGet cannot remove the unavailable package without first restoring it !!!

PM> Install-Package Microsoft.AspNet.SignalR
Install-Package : Some NuGet packages are missing from the solution. The packages need to be restored in order to build the dependency graph. Restore the packages before performing any operations.
At line:1 char:1
+ Install-Package Microsoft.AspNet.SignalR
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [Install-Package], InvalidOperationException
    + FullyQualifiedErrorId : NuGetMissingPackages,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand

然后Package Manager Console上将出现一个Restore按钮,按下该按钮将导致以下错误:

Then there will be a Restore button on the Package Manager Console which pressing it will result in the following error:

如果找不到当前版本的软件包,如何安装更新版本?

我正在使用:

Microsoft Visual Studio Community 2015
Version 14.0.24720.00 Update 1
Microsoft .NET Framework
Version 4.6.01038
NuGet Package Manager   3.3.0

[UPDATE]

当我尝试卸载有问题的软件包时:

When I try to uninstall the troublesome package:

PM> Uninstall-Package -Id Microsfot.AspNet.SignalR -RemoveDependencies -Force
Uninstall-Package : Some NuGet packages are missing from the solution. The packages need to be restored in order to build the dependency graph. Restore the packages before performing any operations.
At line:1 char:1
+ Uninstall-Package -Id Microsfot.AspNet.SignalR -RemoveDependencies -F ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [Uninstall-Package], InvalidOperationException
    + FullyQualifiedErrorId : NuGetMissingPackages,NuGet.PackageManagement.PowerShellCmdlets.UninstallPackageCommand

推荐答案

您可以通过以下方式手动删除依赖项:

You can manually remove the dependency by:

  1. 关闭Visual Studio(不是硬性要求,但有帮助)
  2. 在文本编辑器中,从packages.config中删除依赖项
  3. 从程序包/目录中删除程序包
  4. 在文本编辑器中,从.csproj文件中删除对包的所有引用
  5. 启动Visual Studio
  6. 通过NuGet重新安装软件包

这篇关于由于提到的版本不再可用,因此无法还原/删除/更新NuGet软件包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-03 02:03