Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error : Package restore failed

I am trying to add controller to my solution in Asp.net Core project.

While doing so i am getting this error.

enter image description here

enter image description here

I am getting the same message for adding minimal dependencies and full dependencies for controller.

Please help me with this issue. Thanks in advance.

like image 202
user8038446 Avatar asked Jun 12 '17 22:06

user8038446


People also ask

How do I restore a package in Visual Studio?

In Visual Studio on Windows, you can restore packages automatically or manually. First, configure Package Restore through Tools > Options > NuGet Package Manager.

How do I force a NuGet package to restore?

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.


1 Answers

I also had this issue. "Add Controller>API Controller with actions, using Entity Framework" would give the "Package Restore Failed" error.

As Anish stated, it seems to be due to package versions being mis-aligned. I was able to resolve this issue using "Manage NUGET Packages for Solution", then performing an "Update All". This set my AspNetCore version to 2.1.5 and resolved my "Package Restore Failed" error, but then led to another error, "NETCore version 2.1.5 not found". Apparently the scaffolding code generator needs the AspNetCore and the NETCore versions to be in sync, so I manually downloaded and installed the NETCore version 2.1.5 from Microsoft Downloads. This worked, and I was finally able to generate Controllers.

like image 100
Scott Duncan Avatar answered Oct 11 '22 12:10

Scott Duncan