Installing Packages through Nuget - "Central Directory corrupt"
Remove all nuget packages under \packages\ ( i had multiple corrupted packages)
Go to your solution in Visual Studio and press "Restore Nuget Packages"
Rebuild your solution
Should be fixed :)
Edit 07/2017
A far easier method of solving this issue is be to just get Visual Studio to re-download the package -
- In Visual Studio open
Tools -> Options
. - Select
NuGet Package Manager
. - Ensure both
Allow NuGet to download missing packages
andAutomatically check for missing packages during build in Visual Studio
are both ticked. - Click
OK
. - In a file explorer window navigate into the projects' "packages" folder.
- Three options -
- Figure out which package is at fault as described in the original answer and delete it's folder.
- Move all the packages to a temporary location if you're unsure whether they're all still available in NuGet (you'll need to copy the missing ones back afterwards)
- Delete all the package folders if you are sure all your packages are still available in NuGet.
- Back in Visual Studio build your solution.
- Visual Studio should download all your packages.
Original Answer
Ok, the problem here was that the .nupkg
file for one package (found in project root/packges/package folder) had been corrupted at some point and had a size of zero.
I figured out which package was corrupt after attempting to manually install a random package using the package manager console -
Install-Package *package name*
which told me that there was a problem with a currently installed package -
Install-Package : An error occurred while retrieving package metadata for 'package name'....
From there I was able to fix it by doing the following -
- Navigate to the to the NuGet site
- Search for the project using the search facility at the top of the page
- Download the
.nupkg
file using the "Download" link on the left hand side (checking the version number). - Copy the downloaded file over the old one in the "packages" folder.