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

10

23

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

Guerrilla answered 19/9, 2018 at 7:47 Comment(1)
In the Solution Explorer - Do you see a project by name "MultiLinker.Courier.Dext.Model.csproj" - Is it in Unloaded state? Seems like that project is broken.Cudgel
C
37

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

Cammie answered 30/11, 2018 at 6:29 Comment(2)
I just spent a couple hours on this. Thank you for the solution!Withindoors
The nuget api url is now updated to v3 nuget.org/api/v3Aegisthus
B
11

open Nuget Package Manager -> Package Source > Add https://nuget.org/api/v2

Blimp answered 8/3, 2019 at 19:11 Comment(0)
B
3

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.

Bushweller answered 7/10, 2021 at 21:59 Comment(0)
I
3

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

Account Settings > Change credentials in the dialog that opens

Interbreed answered 18/6, 2022 at 15:55 Comment(0)
R
3

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

dotnet new nugetconfig
Redletter answered 28/7, 2022 at 16:58 Comment(1)
I kept getting some cached nuget sources trying to restore and this was the only thing that prevented them from doing so. Thanks!Parcel
G
0

Upgrading my out of date Visual Studio helped for me:

Help Menu: Check for Updates...

Godric answered 29/5, 2021 at 2:3 Comment(1)
I had the same symptoms as the original question and updating visual studio fixed the issue.Protolithic
J
0

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

Jurel answered 22/9, 2022 at 23:21 Comment(0)
H
0

Before anything, I use Visual Studio 2013.

This worked for me:

  1. Click on Tools > Library Package Manager > Package Manager Console
  2. Paste the following lines on the console: [Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bOR [Net.SecurityProtocolType]::Tls12

Then, rebuild your solution.

Hereinafter answered 1/3, 2023 at 8:14 Comment(0)
V
0

In case it may help someone else. The issue for me was that 2 of my projects were not loading due to a long path. I renamed the folder to something shorter, all my 114 projects loaded successfully, and I was finally able to build my solution without getting the "NuGet package restore failed." error message

Vahe answered 16/7, 2024 at 13:50 Comment(0)
B
-1

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.

Betancourt answered 15/10, 2021 at 1:40 Comment(1)
As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.Bastian

© 2022 - 2025 — McMap. All rights reserved.