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

Viewed 25883

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

8 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

I might be forgetting some steps, but a crucial step for me to fix this was running nuget restore from the commandline (Trying to restore from Visual Studio UI was not sufficient for some reason).

I also added a plugins folder given to me by a teammate to my .nuget folder that supposedly makes it handle our credentials automatically, so if you are having this issue maybe that is something you are missing as well.

In my case it was my Company DevOps credentials being out of date

Account Settings > Change credentials in the dialog that opens

The nuget restore did not work for me but once I used nuget.org it worked just fine. This was the best solution for me.

On Visual Studio Code (VSCode) this can be solved this way:

dotnet new nugetconfig

thank you it works fine and solved all issues of nuget by creating the new value in the setting of nuget under tools > nuget package manger > package manger settings nuget package sources add new value nuget.org and https://www.nuget.org/api/v2/

then save and update you project it will work

Upgrading my out of date Visual Studio helped for me:

Help Menu: Check for Updates...

Related