"End of Central Directory record could not be found" - NuGet in VS community 2015

27,442

Solution 1

Go into your solution folder and delete your "packages" folder. You'll need to right-click your solution and select "Manage packages" and click the "Restore" button at the top of the screen where it tells you the packages are missing.

Solution 2

Remove folder 'packages' in your project folder. Wipe data from these folders:

%USERPROFILE%\.nuget\packages

%USERPROFILE%\AppData\Local\NuGet\v3-cache

%USERPROFILE%\AppData\Local\dnu\cache

Then open solution and right-click to solution tree and click 'Restore NuGet Packages'.

Solution 3

Try next:

D:\src\build>nuget locals -clear all
Clearing NuGet HTTP cache: C:\Users\dzmitry\AppData\Local\NuGet\v3-cache
Clearing NuGet cache: C:\Users\dzmitry\AppData\Local\NuGet\Cache
Clearing NuGet global packages cache: C:\Users\dzmitry\.nuget\packages\
WARNING: Local resources partially cleared.
WARNING: Failed to delete 'C:\Users\dzmitry\.nuget\packages\'.
WARNING: Failed to delete 'C:\Users\dzmitry\.nuget\packages\fsharp.data.xmlprovider\2.3.14159\lib\net40\FSharp.Data.DesignTime.dll'.
Clearing local resources failed: one or more errors occured.

Solution 4

I got this error just now from another silly cause: I'd run out of disk space! If these solutions aren't working for you, that's another thing to check.

Share:
27,442
Vishnu Prasad V
Author by

Vishnu Prasad V

When the Sun is up, Code like my life depends on it. When it's not, play Football or go read reddit

Updated on July 05, 2022

Comments

  • Vishnu Prasad V
    Vishnu Prasad V almost 2 years

    I am getting an error when i try to install any package from the NuGet in VS community edition 2015.

    Attempting to gather dependencies information for package 'Microsoft.Net.Http.2.2.29' with respect to project 'ClassLibrary1', targeting '.NETFramework,Version=v4.5.2'
    Attempting to resolve dependencies for package 'Microsoft.Net.Http.2.2.29' with DependencyBehavior 'Lowest'
    Resolving actions to install package 'Microsoft.Net.Http.2.2.29'
    Resolved actions to install package 'Microsoft.Net.Http.2.2.29'
    Install failed. Rolling back...
    Package 'Microsoft.Bcl.Build 1.0.14' does not exist in project 'ClassLibrary1'
    Package 'Microsoft.Bcl.Build 1.0.14' does not exist in folder 'C:\Users\441793\documents\visual studio 2015\Projects\ClassLibrary1\packages'
    System.IO.InvalidDataException: End of Central Directory record could not be found.
       at System.IO.Compression.ZipArchive.ReadEndOfCentralDirectory()
       at System.IO.Compression.ZipArchive.Init(Stream stream, ZipArchiveMode mode, Boolean leaveOpen)
       at System.IO.Compression.ZipArchive..ctor(Stream stream, ZipArchiveMode mode, Boolean leaveOpen, Encoding entryNameEncoding)
       at System.IO.Compression.ZipArchive..ctor(Stream stream, ZipArchiveMode mode)
       at NuGet.Packaging.NuGetPackageUtils.ExtractPackage(String targetPath, FileStream stream)
       at NuGet.Packaging.NuGetPackageUtils.<>c__DisplayClass1_0.<<InstallFromStreamAsync>b__0>d.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---
       at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
       at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
       at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
       at NuGet.Common.ConcurrencyUtilities.<ExecuteWithFileLocked>d__0`1.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---
       at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
       at NuGet.Common.ConcurrencyUtilities.<ExecuteWithFileLocked>d__0`1.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---
       at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
       at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
       at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
       at NuGet.Packaging.NuGetPackageUtils.<InstallFromStreamAsync>d__1.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---
       at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
       at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
       at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
       at NuGet.Protocol.Core.v3.GlobalPackagesFolderUtility.<AddPackageAsync>d__1.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---
       at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
       at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
       at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
       at NuGet.Protocol.Core.v3.DownloadResourceV3.<GetDownloadResourceResultAsync>d__4.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---
       at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
       at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
       at NuGet.PackageManagement.PackageDownloader.<GetDownloadResourceResultAsync>d__1.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---
       at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
       at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
       at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
       at NuGet.PackageManagement.NuGetPackageManager.<ExecuteNuGetProjectActionsAsync>d__42.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---
       at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
       at NuGet.PackageManagement.NuGetPackageManager.<ExecuteNuGetProjectActionsAsync>d__42.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---
       at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
       at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
       at NuGet.PackageManagement.UI.UIActionEngine.<ExecuteActionsAsync>d__5.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---
       at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
       at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
       at NuGet.PackageManagement.UI.UIActionEngine.<PerformActionAsync>d__3.MoveNext()
    ========== Finished ==========
    

    Error message i receive is in the Error List tab is

    End of Central Directory record could not be found
    

    I tried from Console application to Class libraries and getting this error for all packages i tried to install.

    NuGet Version is : 3.0.60624.657

    Any help will be appreciated

  • Gerke Geurts
    Gerke Geurts over 5 years
    Clearing the NuGet cache solved this problem for me as well, in this case when using Visual Studio 2017 and package references rather than packages.config.
  • Christian
    Christian about 2 years
    If you have got a local NuGet package folder (package source on your disk) where your locally created packages are stored, make sure to clear that folder as well. That solved the issue for me.