[英]Installing Packages through Nuget - "Central Directory corrupt"
I'm trying to add a package to my project using NuGet (in VS2015).我正在尝试使用 NuGet(在 VS2015 中)向我的项目添加一个包。 When I click the "Install" button I see
当我点击“安装”按钮时,我看到
Downloading missing packages...
正在下载丢失的包...
at the top of the screen with a progress bar.在屏幕顶部有一个进度条。
After a moment the message is replaced with -片刻之后,消息被替换为 -
An error occurred while trying to restore packages: Central Directory corrupt.
尝试恢复包时发生错误:中央目录已损坏。
with a "Restore" button at the end which does the same process.最后有一个“恢复”按钮,它执行相同的过程。
Anyone have any idea how to fix this?任何人都知道如何解决这个问题?
Edit 07/2017编辑 07/2017
A far easier method of solving this issue is be to just get Visual Studio to re-download the package -解决此问题的一种更简单的方法是让 Visual Studio 重新下载包 -
Tools -> Options
.Tools -> Options
。NuGet Package Manager
.NuGet Package Manager
。Allow NuGet to download missing packages
and Automatically check for missing packages during build in Visual Studio
are both ticked.Allow NuGet to download missing packages
和Automatically check for missing packages during build in Visual Studio
。OK
.OK
。 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.好的,这里的问题是一个包的
.nupkg
文件(在项目根/packges/包文件夹中找到)在某个时候已损坏并且大小为零。
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 -从那里我可以通过执行以下操作来修复它 -
.nupkg
file using the "Download" link on the left hand side (checking the version number)..nupkg
文件(检查版本号)。 Remove all nuget packages under \packages\ ( i had multiple corrupted packages)删除 \packages\ 下的所有 nuget 包(我有多个损坏的包)
Go to your solution in Visual Studio and press "Restore Nuget Packages"在 Visual Studio 中转到您的解决方案,然后按“恢复 Nuget 包”
Rebuild your solution重建您的解决方案
Should be fixed:)应该修复:)
1.First of all read the error. 1.首先阅读错误。
2.Find the Directory listed on error console. 2.找到错误控制台上列出的目录。 1.File Explorer ==>>
1.文件资源管理器==>>
For Example, My Path is.例如,我的路径是。 C:\Code\Ex_Nikesh\20\packages In Packages Find Microsoft.SqlServer.Types.xx.xxx.xx.xx (xx indicates version number)
C:\Code\Ex_Nikesh\20\packages在Packages中找到Microsoft.SqlServer.Types.xx.xxx.xx.xx (xx表示版本号)
3.Inside the folder find Microsoft.SqlServer.Types.xx.xxx.xx.xx.nu (Nuget Package File [In My case file size is 0 KB]) Delete that File. 3.在文件夹中找到Microsoft.SqlServer.Types.xx.xxx.xx.xx.nu (Nuget 包文件 [在我的情况下文件大小为 0 KB])删除该文件。
4. Now Download the File and Paste inside Microsoft.SqlServer.Types.xx.xxx.xx.xx Folder Click Here for Download Nuget File 4.现在下载文件并粘贴到 Microsoft.SqlServer.Types.xx.xxx.xx.xx 文件夹中 点击这里下载 Nuget 文件
My problem was a corrupted zip file in the following folder: C:\Program Files (x86)\Microsoft SDKs\NuGetPackages我的问题是以下文件夹中的损坏 zip 文件:C:\Program Files (x86)\Microsoft SDKs\NuGetPackages
I cleared all these packages (offline repository)我清除了所有这些包(离线存储库)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.