简体   繁体   English

尝试在新解决方案中启用NuGet包还原时出错

[英]Error when trying to enable NuGet Package Restore in new Solution

I am getting an error when trying to enable package restore in a new solution I just created. 尝试在刚刚创建的新解决方案中启用包还原时出现错误。 The error in VS2012 is: VS2012中的错误是:

NuGet Package Manager NuGet包管理器

An error occurred while configuring the solution to restore NuGet packages on build 配置解决方案以在构建时还原NuGet包时发生错误

Unable to read package from path 'NuGet.Build.2.7.0.npkg'. 无法从路径'NuGet.Build.2.7.0.npkg'读取包。

I tried opening the solution in VS2010 to work around the problem and I am also getting an error when trying to enable package restore, but the message is different: 我尝试在VS2010中打开解决方案来解决问题,我在尝试启用包恢复时也遇到错误,但消息不同:

NuGet Package Manager NuGet包管理器

An error occurred while configuring the solution to restore NuGet packages on build 配置解决方案以在构建时还原NuGet包时发生错误

Archive file cannot be size 0. 存档文件的大小不能为0。

I tried creating a new solution, but got the same result. 我尝试创建一个新的解决方案,但得到了相同的结果。

I then tried doing a repair on VS2012 update 3 and rebooting. 然后我尝试在VS2012更新3上进行修复并重新启动。 Still getting the problem. 仍然遇到问题。

I also scanned the folder, project, and solution file for anything NuGet or .nupkg, but there is nothing there. 我还扫描了文件夹,项目和解决方案文件中的任何NuGet或.nupkg,但没有任何内容。

So how can I get this feature working again? 那么我怎样才能让这个功能再次运行? The last time I used it was about a week ago, and I don't remember specifically what I changed since then. 我最后一次使用它是在大约一个星期前,我不记得我从那时起改变了什么。 I uninstalled the VS Power Tools package that I installed about a week ago, but that didn't fix the problem either. 我卸载了大约一周前安装的VS Power Tools软件包,但这也没有解决问题。

Update 更新

I followed the "removal" instructions here and used a project I already have as a template to enable package restore manually. 我在这里按照“删除”说明并使用我已经拥有的项目作为模板来手动启用包恢复。 However, I am still looking for a better solution because this is a feature I use frequently. 但是,我仍在寻找更好的解决方案,因为这是我经常使用的功能。

I also tried uninstalling and reinstalling NuGet from visual studio, but I still get the same issue. 我也尝试从visual studio卸载并重新安装NuGet,但我仍然遇到同样的问题。 If memory serves correctly, there was a recent NuGet update (is there a log for VS extension installation so I can check?). 如果内存服务正常,最近有一个NuGet更新(是否有VS扩展安装的日志,所以我可以检查?)。

I suspect that the NuGet.Build.2.7.0.npkg file is zero bytes due to a failed download. 我怀疑由于下载失败,NuGet.Build.2.7.0.npkg文件为零字节。 NuGet.Build.2.7.0.npkg is the NuGet package that Visual Studio downloads in order to enable package restore for your solution. NuGet.Build.2.7.0.npkg是Visual Studio下载的NuGet包,以便为您的解决方案启用包还原。

Take a look in your cache and see if this file is zero bytes. 查看缓存并查看此文件是否为零字节。 If so then delete the file or clearing the cache and try enabling package restore again. 如果是,则删除文件或清除缓存,然后再次尝试启用包还原。 The cache is under your profile in a directory similar to: 缓存位于您的配置文件下的类似于以下目录中:

C:\Users\YourUsername\AppData\Local\NuGet\Cache

You can also browse to the cache from inside Visual Studio by opening the Package Manager Settings, selecting General and clicking the Browse button. 您还可以通过打开“包管理器设置”,选择“常规”并单击“浏览”按钮,从Visual Studio内部浏览到缓存。

所有以前的答案,加上这一个:你可以运行。\\ nuget \\ nuget.exe update -self如果这是一个先前启用了包恢复的解决方案吗?

check whether your nuget package manager is updated one or not. 检查您的nuget包管理器是否已更新。 Check this from Tools-> Extensions and Updates -> Updates 从工具 - >扩展和更新 - >更新中检查这一点

Update your Nuget Package Manager and then it will work 更新您的Nuget包管理器,然后它将工作

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM