gpt4 book ai didi

visual-studio - 无法恢复/删除/更新 NuGet 包,因为提到的版本不再可用

转载 作者:行者123 更新时间:2023-12-03 07:41:08 24 4
gpt4 key购买 nike

我正在尝试给出 SignalR Sample试驾,但似乎它引用了旧版本的 SignalR,该版本不再可用。实际问题是 NuGet 在不先恢复不可用的包的情况下无法删除它!!!

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按钮,按下该按钮将导致以下错误:

An error occurred while trying to restore packages: Unable to find version '2.1.0-pre-131116-b279' of package 'Microsoft.AspNet.SignalR.Client'

如果找不到当前版本,如何安装已寻址软件包的较新版本?

我正在使用:

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

[更新]

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

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

最佳答案

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

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

关于visual-studio - 无法恢复/删除/更新 NuGet 包,因为提到的版本不再可用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34147484/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com