6

I right click on my solution file in my VS2010 and clicked Enable NuGet Package Restore, and I got an error message saying Unable to read package from path 'NuGet.CommandLine.2.7.1.nupkg'.

I googled around and don't see anything close.

Any clue?

hardywang
  • 4,864
  • 11
  • 65
  • 101

2 Answers2

12

The error message is usually because NuGet cannot open the NuGet package because it failed to download it. I would check your NuGet cache to see if the NuGet.CommandLine.2.7.1.nupkg file is zero bytes or smaller than expected. If so delete the file or clear the cache and try again. Sometimes the download can fail and NuGet leaves an empty file in the cache which causes problems on installing that NuGet package. You can also see the error if the NuGet package did not fully download, so the package will not be zero bytes but will not have fully downloaded and NuGet cannot open it. So it is worth deleting the NuGet package from the cache and retrying.

The NuGet cache is in the following directory:

%localappdata%\NuGet\Cache

You can also browse to the NuGet cache from inside Visual Studio by opening the Package Manager Settings, selecting General and clicking the Browse button.

Note that with newer versions of NuGet 2.8 this problem should be fixed. NuGet in later versions will download to a temporary file location and renamed once the download is completed so a partially download NuGet package will not be left in the cache.

Community
  • 1
  • 1
Matt Ward
  • 47,057
  • 5
  • 93
  • 94
  • I have just checked my NuGet.CommandLine.2.7.1.nupkg has 416KB size. – hardywang Oct 28 '13 at 12:58
  • 1
    NuGet.CommandLine.2.7.1.nupkg is 446KB. I suspect the package did not download properly. I would delete it and try again. To test the package you can change the file extension to .zip and see if you can open it. – Matt Ward Nov 03 '13 at 18:37
  • You know, I should say thanks a ton. I was stuck in this issue for quite some time – Shanadas Oct 15 '15 at 09:06
0

go to this location and delete the nupkg file C:\ProgramData\chocolatey\lib\openjdk11