Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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:

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?).

like image 900
NightOwl888 Avatar asked Sep 09 '13 19:09

NightOwl888


1 Answers

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.

like image 70
Matt Ward Avatar answered Sep 23 '22 10:09

Matt Ward