I am getting an error when trying to enable package restore in a new solution I just created. The error in VS2012 is:

NuGet Package Manager

An error occurred while configuring the solution to restore NuGet packages on build

Unable to read package from path '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:

NuGet Package Manager

An error occurred while configuring the solution to restore NuGet packages on build

Archive file cannot be size 0.

I tried creating a new solution, but got the same result.

I then tried doing a repair on VS2012 update 3 and rebooting. Still getting the problem.

I also scanned the folder, project, and solution file for anything NuGet or .nupkg, but there is nothing there.

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.

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. If memory serves correctly, there was a recent NuGet update (is there a log for VS extension installation so I can check?).

有帮助吗?

解决方案

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 is the NuGet package that Visual Studio downloads in order to enable package restore for your solution.

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.

其他提示

All of the previous answers, plus this one: can you run .\nuget\nuget.exe update -self if this is a solution in which package restore was previously enabled?

check whether your nuget package manager is updated one or not. Check this from Tools-> Extensions and Updates -> Updates

Update your Nuget Package Manager and then it will work

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top