Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to resolve "NuGet package restore failed" in Visual Studio?

I got an error

NuGet package restore failed. Please see Error List window for detailed warnings and errors.

while building my solution. Package manager can't restore my 2 projects:

Unable to find project information for 'C:\(...)\MultiLinker.Courier.Dext.Model.csproj'. The project file may be invalid or missing targets required for restore.

In tools I allow package manage to download packages:

enter image description here

like image 756
paprykarz Avatar asked Sep 19 '18 07:09

paprykarz


People also ask

How do I fix NuGet recovery failed?

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

How do I enable NuGet package restore in Visual Studio?

To do that, go to Tools, NuGet Packaged Manager, then go to Package Manager Settings. Go to the General section, and then make sure you have a checkmark for Allow NuGet to download missing packages and also to automatically check for missing packages during the build in Visual Studio. So click on OK.

How do I force a NuGet package to restore?

Restore NuGet packagesNavigate to Tools > Options > NuGet Package Manager > General, and then select the Allow NuGet to download missing packages check box under Package Restore. Enabling Restore NuGet Packages. In Solution Explorer, right-click the solution, and then select Restore NuGet Packages.

How do I reinstall NuGet restore?

After you enable package restore in Options, you can right-click the solution in Solution Explorer and select Restore NuGet Packages to restore packages anytime. If you enabled automatic restore in Options, Package Restore happens automatically when you create a project from a template or build a project.


1 Answers

Ran into the same issue. In my case, it was because Visual Studio only had the Offline Package source and could not resolve the packages I needed. I added in the nuget.org source as shown below in the NuGet Package Manager settings and right clicked on the solution and selected restore packages. and it resolved the issue.

screen cap

like image 185
Bernesto Avatar answered Sep 22 '22 13:09

Bernesto