Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Package restore failed. Rolling back package changes VS2019

 scaffolding was not worked The package restore failed. Rolling back package changes in VS2019 for asp.net core. When,I try to add API Controller using EF. This didn't work for me -Try to Clear All Nuget Caches , -Try clearing the ComponentModelCache Can't Add View from Controller in VS 2015 : "There was an error running the selected code generator" It does not solve this error.

can anyone help me?

like image 991
Risk Avatar asked Aug 24 '20 12:08

Risk


People also ask

How can I restore my package in Visual Studio 2019?

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 reinstall NuGet packages in Visual Studio 2019?

Switch to the Browse tab, search for the package name, select it, then select Install). For all packages, delete the package folder, then run nuget install . For a single package, delete the package folder and use nuget install <id> to reinstall the same one.

What does MSBuild restore do?

MSBuild -t:restore (which nuget restore and dotnet restore use with . NET Core projects), restores packages referenced in the project file as follows: Read all project to project references.

Why am I getting a package restore error in Visual Studio?

This error indicates that package restore is disabled in your NuGet configuration. You can change the applicable settings in Visual Studio as described earlier under Quick solution for Visual Studio users.

What do I do when my package restore fails?

Rolling back package changes This article discusses what to do when your package restore fails. 1. In Visual Studio 2019, goto Tools > Options > Nuget Package Manager > Package Manager Setting > General > Clear All Nuget Cache (s).

How to debug rolling back package changes in Visual Studio?

Rolling back package changes once you get this msg open your output window. it will show all the packages it installed and where it has failed and started restoring. From there you will be able to debug it. For people who are getting error for Microsoft.AspNetCore.All. please go to project>properties>application>target Framework.

How do I restore NuGet packages in Visual Studio?

(In Visual Studio, the references appear in Solution Explorer under the Dependencies \ NuGet or the References node.) To follow the required steps to restore packages, see Restore packages.


4 Answers

I had the same issue while adding the view for an IActionResult in .net 5.0 MVC using VS2019, before updating all the installed packages.

For me, restarting the Visual Studio works.

After restart I tried again, auto scaffolding installed this package "Microsoft.VisualStudio.Web.CodeGeneration.Design" along with generating a View.

like image 156
Umair Ijaz Avatar answered Oct 13 '22 20:10

Umair Ijaz


For EF Core packages version 5.0.5 I was only able to solve this using the command line tool. See answer by johanjuulj here Visual Studio error: There was an error running the selected code generator

dotnet aspnet-codegenerator controller -m MyModel -dc MyDbContext -name MyModelssController -async
like image 22
Nick Pearce Avatar answered Oct 13 '22 21:10

Nick Pearce


1 - Go to Tools

2 - Options

3- NuGet Package Manager

4- General

5 - Clear All NuGet Cache(s)

like image 24
Kürşat Yıldırım Avatar answered Oct 13 '22 21:10

Kürşat Yıldırım


There are a couple of reasons that might account for this behaviour. Some of the reasons, as I have experienced on different occasions, include but might not be limited to the following:

  1. Outdated Visual Studio Environment: In this case, you might attempt to update your version of VS.

  2. Outdated Packages: In this case, update some or all of the packages in your project. To do this, go to Tools -> Nuget Package Manager -> Manage Nuget Package for Solution. Choose the packages that you want to update. if you are not sure, check Select all packages

like image 22
Ààrẹ Àgò Avatar answered Oct 13 '22 21:10

Ààrẹ Àgò