Visual Studio 2017 年的 Nuget 包错误

Nuget package error in Visual Studio 2017

我在 Visual studio 2017 年构建解决方案时遇到错误。

"The package ComponentAce.Compression.Libs.zlib with version 1.0.4 could not be found in C:\Users\.nuget\packages. Run a NuGet package restore to download the package.".

我的代码是 .net 4.7.2 (C#,WPF)

我尝试 install/uninstall/rebuild/clean 并且我还完全删除了代码中对该包的所有引用。什么都不起作用。知道这里有什么问题吗?

在工具 -> 选项下启用 'Allow Nuget to download missing packages'

参见Trouble-shooting nuget issues

  1. 您可以通过 VS IDE 清理缓存(Go Tools => Options => Nuget Package Manager => Settings => Clear Nuget caches)。之后,重新清理并构建当前项目。

  2. 如果问题仍然存在,请打开您的解决方案目录=> 关闭VS 实例=> 删除.vs 文件夹,并删除项目目录中的bin 和obj 文件夹。然后重建项目。

  3. 如果以上都没有帮助,这可能是一个类似的问题 here, update VS2017 到最新的 15.9.16 修复它。

更新:

could not be found in C:\Users.nuget\packages

1.What具体路径长什么样?应该是 C:\user\user-name\.nuget\packages by default, if the error you got is C:\Users\.nuget\packages, I think you may have a custom nuget.config 文件导致了这个问题。

2.Also,您可以创建一个新的空项目并在该项目中安装缺少的包。比关闭空项目,重新打开原来的项目要运行 重建。来自 marco6 的提示。