Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.Net Core project Nuget Packages Can not restore

I want to restore my Identity Server 4 project, after open VS2017 but when package manager try to restore references, it gets fail error every time.

I use latest version of VS2017 and my core packages installed and updated on my pc.

Error The feed 'nuget.org [https://api.nuget.org/v3/index.json]' lists package 'Microsoft.AspNetCore.2.1.3' but multiple attempts to download the nupkg have failed. The feed is either invalid or required packages were removed while the current operation was in progress. Verify the package exists on the feed and try again. Unable to find package 'Microsoft.AspNetCore.2.1.3'.

enter image description here

like image 231
Ugur Ozker Avatar asked Sep 12 '18 14:09

Ugur Ozker


People also ask

How do I force a NuGet package to restore?

Restore packages manually using Visual Studio Enable package restore by choosing Tools > Options > NuGet Package Manager. Under Package Restore options, select Allow NuGet to download missing packages. In Solution Explorer, right click the solution and select Restore NuGet Packages.

How do I fix a NuGet package error?

Quick solution for Visual Studio users Select the Tools > NuGet Package Manager > Package Manager Settings menu command. Set both options under Package Restore. Select OK. Build your project again.

Does dotnet restore use NuGet?

The dotnet restore command uses NuGet to restore dependencies as well as project-specific tools that are specified in the project file. In most cases, you don't need to explicitly use the dotnet restore command, since a NuGet restore is run implicitly if necessary when you run the following commands: dotnet new.

Was not found it might have been deleted since NuGet restore?

It might have been deleted since NuGet restore. Otherwise, NuGet restore might have only partially completed, which might have been due to maximum path length restrictions. Here are some actions you can take to resolve this error: Add the /restore option to your MSBuild.exe command.

How do I restore a NuGet project?

Restore using the nuget.exe CLI Use the restore command, which downloads and installs any packages missing from the packages folder. For projects migrated to PackageReference, use msbuild -t:restore to restore packages instead.

How to fix NuGet packages not working in Visual Studio?

Try updating your Visual Studio to the lastest version, sometimes the updates helps you solve package issues which was previously not supported. Right-click on the Solution and click "Restore NuGet Packages" option. Or you can try executing this console command in the folder that has your solution file:

Why does NuGet take packages from multiple sources during restore?

If the package isn't in the cache, NuGet tries to download the package from all enabled sources in the list at Tools > Options > NuGet Package Manager > Package Sources in Visual Studio. During restore, NuGet ignores the order of package sources, and uses the package from whichever source is first to respond to requests.

What is NuGet and how does it work?

When you add a NuGet package to your project, NuGet essentially does two things: It downloads the package and puts it in your solution under a directory called “packages”. It installs the package to your project.


1 Answers

According to the message in the error log:

end of central directory record could not be found

You can try the following troubleshooting steps to resolve this issue:

  • Clean the entire NuGet package cache by the command:
    nuget locals all -clear
    
  • Close all Visual Studio instances, delete the nuget.config file in the location:
    C:\Users\leoliu\AppData\Roaming\NuGet\NuGet.Config
    
    and then reopen Visual Studio to restore NuGet packages.
  • Check if there is a firewall policy or other proxy settings that is blocking the NuGet installation package.
like image 157
Leo Liu-MSFT Avatar answered Oct 23 '22 06:10

Leo Liu-MSFT