16

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

NightOwl888
  • 55,572
  • 24
  • 139
  • 212
  • You can enable logging in VS by running devenv.exe /log then look for customactivity.xml – Mike Cheel Sep 09 '13 at 20:32
  • Yea, but that wouldn't do much good for something that happened a week ago... I am looking for something similar to the way Windows Update has an install log of updates. – NightOwl888 Sep 09 '13 at 21:20
  • If you can reproduce I found this: http://stackoverflow.com/questions/10356981/does-nuget-create-an-error-log-file-when-a-package-is-installed – Mike Cheel Sep 10 '13 at 01:26
  • Thanks, but again not what I need. I am not troubleshooting the installation of a NuGet package, but was trying to find a historical list of VSIX package updates I did to Visual Studio that could be interfering with this feature. – NightOwl888 Sep 10 '13 at 10:12
  • Sorry didn't understand what you wanted. – Mike Cheel Sep 10 '13 at 13:14

3 Answers3

22

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.

Matt Ward
  • 47,057
  • 5
  • 93
  • 94
  • 1
    Your solution worked great. The error message would have been much more helpful if it gave the full path to the file it was looking for because I had no idea where to look. – NightOwl888 Sep 13 '13 at 08:31
  • In My Machine the path is "C:\Users\YourUsername\AppData\Roaming\NuGet" – Satish Kumar sonker Sep 12 '17 at 08:46
  • The cache should not be under your roaming profile. The NuGet.Config file will be under your roaming profile. The cache folder mentioned in the answer is also specific to NuGet v2. – Matt Ward Sep 12 '17 at 09:06
0

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?

maartenba
  • 3,344
  • 18
  • 31
0

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

S.Akruwala
  • 1,446
  • 12
  • 8