"Nuget failed to restore packages",但之前运行良好

"Nuget failed to restore packages", but it worked fine before

在启动时出现损坏的注册表警告后,我通过简单地将 windows 恢复到某个更新之前的状态,成功地再次获得了我的 PC 运行。然而,由于一些完全未知的原因,Visual Studio 然后开始表现得很奇怪。首先,它没有检测到对 Renci.SSH.NET 的引用,即使它显然存在。所以我进入了 nuget 包管理器,卸载了 SSH.NET,希望之后我可以重新安装它,一切都会好起来的。

显然,一切都没有那么顺利。如果我使用包管理器 GUI,Visual Studio 会告诉我 "Failed to restore package. Restoring package modifications for 'BlankApplication'."。如果我使用 nuget 控制台并键入 PM > Install-Package SSH.NET,我会在红色噩梦中突出显示:

Install-Package : SSH.NET 2016.0.0 is not compatible with UAP,Version=v10.0.
Au caractère Ligne:1 : 1
+ Install-Package SSH.NET
+ ~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Install-Package], Exception
    + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand

Install-Package : SshNet.Security.Cryptography 1.2.0 is not compatible with UAP,Version=v10.0.
Au caractère Ligne:1 : 1
+ Install-Package SSH.NET
+ ~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Install-Package], Exception
    + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand

Install-Package : System.Xml.XPath.XmlDocument 4.0.1 is not compatible with UAP,Version=v10.0.
Au caractère Ligne:1 : 1
+ Install-Package SSH.NET
+ ~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Install-Package], Exception
    + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand

Install-Package : System.Xml.XPath 4.0.1 is not compatible with UAP,Version=v10.0.
Au caractère Ligne:1 : 1
+ Install-Package SSH.NET
+ ~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Install-Package], Exception
    + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand

Install-Package : Some packages are not compatible with UAP,Version=v10.0.
Au caractère Ligne:1 : 1
+ Install-Package SSH.NET
+ ~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Install-Package], Exception
    + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand

Install-Package : SSH.NET 2016.0.0 is not compatible with UAP,Version=v10.0 (win10-arm).
Au caractère Ligne:1 : 1
+ Install-Package SSH.NET
+ ~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Install-Package], Exception
    + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand

Install-Package : SshNet.Security.Cryptography 1.2.0 is not compatible with UAP,Version=v10.0 (win10-arm).
Au caractère Ligne:1 : 1
+ Install-Package SSH.NET
+ ~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Install-Package], Exception
    + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand

Install-Package : System.Xml.XPath.XmlDocument 4.0.1 is not compatible with UAP,Version=v10.0 (win10-arm).
Au caractère Ligne:1 : 1
+ Install-Package SSH.NET
+ ~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Install-Package], Exception
    + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand

Install-Package : System.Xml.XPath 4.0.1 is not compatible with UAP,Version=v10.0 (win10-arm).
Au caractère Ligne:1 : 1
+ Install-Package SSH.NET
+ ~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Install-Package], Exception
    + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand

Install-Package : Some packages are not compatible with UAP,Version=v10.0 (win10-arm).
Au caractère Ligne:1 : 1
+ Install-Package SSH.NET
+ ~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Install-Package], Exception
    + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand

Install-Package : SSH.NET 2016.0.0 is not compatible with UAP,Version=v10.0 (win10-arm-aot).
Au caractère Ligne:1 : 1
+ Install-Package SSH.NET
+ ~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Install-Package], Exception
    + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand

Install-Package : SshNet.Security.Cryptography 1.2.0 is not compatible with UAP,Version=v10.0 (win10-arm-aot).
Au caractère Ligne:1 : 1
+ Install-Package SSH.NET
+ ~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Install-Package], Exception
    + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand

Install-Package : System.Xml.XPath.XmlDocument 4.0.1 is not compatible with UAP,Version=v10.0 (win10-arm-aot).
Au caractère Ligne:1 : 1
+ Install-Package SSH.NET
+ ~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Install-Package], Exception
    + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand

Install-Package : System.Xml.XPath 4.0.1 is not compatible with UAP,Version=v10.0 (win10-arm-aot).
Au caractère Ligne:1 : 1
+ Install-Package SSH.NET
+ ~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Install-Package], Exception
    + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand

Install-Package : Some packages are not compatible with UAP,Version=v10.0 (win10-arm-aot).
Au caractère Ligne:1 : 1
+ Install-Package SSH.NET
+ ~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Install-Package], Exception
    + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand

Install-Package : SSH.NET 2016.0.0 is not compatible with UAP,Version=v10.0 (win10-x64).
Au caractère Ligne:1 : 1
+ Install-Package SSH.NET
+ ~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Install-Package], Exception
    + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand

Install-Package : SshNet.Security.Cryptography 1.2.0 is not compatible with UAP,Version=v10.0 (win10-x64).
Au caractère Ligne:1 : 1
+ Install-Package SSH.NET
+ ~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Install-Package], Exception
    + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand

Install-Package : System.Xml.XPath.XmlDocument 4.0.1 is not compatible with UAP,Version=v10.0 (win10-x64).
Au caractère Ligne:1 : 1
+ Install-Package SSH.NET
+ ~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Install-Package], Exception
    + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand

Install-Package : System.Xml.XPath 4.0.1 is not compatible with UAP,Version=v10.0 (win10-x64).
Au caractère Ligne:1 : 1
+ Install-Package SSH.NET
+ ~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Install-Package], Exception
    + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand

Install-Package : Some packages are not compatible with UAP,Version=v10.0 (win10-x64).
Au caractère Ligne:1 : 1
+ Install-Package SSH.NET
+ ~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Install-Package], Exception
    + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand

Install-Package : SSH.NET 2016.0.0 is not compatible with UAP,Version=v10.0 (win10-x64-aot).
Au caractère Ligne:1 : 1
+ Install-Package SSH.NET
+ ~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Install-Package], Exception
    + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand

Install-Package : SshNet.Security.Cryptography 1.2.0 is not compatible with UAP,Version=v10.0 (win10-x64-aot).
Au caractère Ligne:1 : 1
+ Install-Package SSH.NET
+ ~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Install-Package], Exception
    + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand

Install-Package : System.Xml.XPath.XmlDocument 4.0.1 is not compatible with UAP,Version=v10.0 (win10-x64-aot).
Au caractère Ligne:1 : 1
+ Install-Package SSH.NET
+ ~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Install-Package], Exception
    + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand

Install-Package : System.Xml.XPath 4.0.1 is not compatible with UAP,Version=v10.0 (win10-x64-aot).
Au caractère Ligne:1 : 1
+ Install-Package SSH.NET
+ ~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Install-Package], Exception
    + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand

Install-Package : Some packages are not compatible with UAP,Version=v10.0 (win10-x64-aot).
Au caractère Ligne:1 : 1
+ Install-Package SSH.NET
+ ~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Install-Package], Exception
    + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand

Install-Package : SSH.NET 2016.0.0 is not compatible with UAP,Version=v10.0 (win10-x86).
Au caractère Ligne:1 : 1
+ Install-Package SSH.NET
+ ~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Install-Package], Exception
    + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand

Install-Package : SshNet.Security.Cryptography 1.2.0 is not compatible with UAP,Version=v10.0 (win10-x86).
Au caractère Ligne:1 : 1
+ Install-Package SSH.NET
+ ~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Install-Package], Exception
    + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand

Install-Package : System.Xml.XPath.XmlDocument 4.0.1 is not compatible with UAP,Version=v10.0 (win10-x86).
Au caractère Ligne:1 : 1
+ Install-Package SSH.NET
+ ~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Install-Package], Exception
    + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand

Install-Package : System.Xml.XPath 4.0.1 is not compatible with UAP,Version=v10.0 (win10-x86).
Au caractère Ligne:1 : 1
+ Install-Package SSH.NET
+ ~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Install-Package], Exception
    + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand

Install-Package : Some packages are not compatible with UAP,Version=v10.0 (win10-x86).
Au caractère Ligne:1 : 1
+ Install-Package SSH.NET
+ ~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Install-Package], Exception
    + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand

Install-Package : SSH.NET 2016.0.0 is not compatible with UAP,Version=v10.0 (win10-x86-aot).
Au caractère Ligne:1 : 1
+ Install-Package SSH.NET
+ ~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Install-Package], Exception
    + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand

Install-Package : SshNet.Security.Cryptography 1.2.0 is not compatible with UAP,Version=v10.0 (win10-x86-aot).
Au caractère Ligne:1 : 1
+ Install-Package SSH.NET
+ ~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Install-Package], Exception
    + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand

Install-Package : System.Xml.XPath.XmlDocument 4.0.1 is not compatible with UAP,Version=v10.0 (win10-x86-aot).
Au caractère Ligne:1 : 1
+ Install-Package SSH.NET
+ ~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Install-Package], Exception
    + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand

Install-Package : System.Xml.XPath 4.0.1 is not compatible with UAP,Version=v10.0 (win10-x86-aot).
Au caractère Ligne:1 : 1
+ Install-Package SSH.NET
+ ~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Install-Package], Exception
    + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand

Install-Package : Some packages are not compatible with UAP,Version=v10.0 (win10-x86-aot).
Au caractère Ligne:1 : 1
+ Install-Package SSH.NET
+ ~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Install-Package], Exception
    + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand

但这没有任何意义。几分钟前它运行良好。我试过卸载并重新安装 nuget、清理项目、清除 %AppData% 中与 NuGet 相关的所有内容,但没有任何效果。另外,请注意,如果我尝试创建一个新的空白项目,也会发生这种情况。

编辑:错误也发生在 Microsoft.Toolkit.UWP 上,具有与 UAP,Version=v.10.0 不兼容的相同症状。在崩溃之前,我还在我的项目中添加了这个包。但是,对于之前未安装的任何其他软件包,我不会遇到此问题。

我终于找到了解决方案:

  • 下载最新的nuget.exehere

  • 通过以管理员身份打开 cmd 清除 nuget 缓存,其中 nuget.exe 和 运行 nuget locals all -clear

  • 重新安装项目中的所有内容。这可能需要一段时间,但它解决了我的问题。
  • 如果您的系统目前看起来特别不稳定,请创建一个系统还原点。你永远不知道。