Error : Package restore failed

package restore failed .net core
there was an error running the selected code generator: 'package restore failed
all packages and projects are compatible with netcoreapp version v2 1 package restore failed
there was an error running the selected code generator scaffolding failed
.net core build tools
asp net core
.net core nuget package location
how to install net core

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

While doing so i am getting this error.

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

Please help me with this issue. Thanks in advance.

For work around,

I suggest you to create a new project and copy the code.

I got the same error before. You are getting this error because you updated NUGET packages in your project which you should not do.

Package restore failed. Rolling back package changes for , when i try to install the identity package in core application then i get this error and package does not install even does not update the packages. "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".

I just recently ran into the same issue.

I resolved it by eventually taking a look at each individual .csproj files included in my solution and fixing all the versions of the microsoft libraries that were included.

I changed the metapackage that i was referencing from "Microsoft.AspNetCore.All" to "Microsoft.AspNetCore.App", i then loaded up the reference list on nuget for the "App" package and removed any references to libraries that are already included in the metapackage.

I then made sure that i fixed the versions of any outstanding packages to match the version of the metapackage that the project automatically chooses ie in my case 2.2.0.

Something that tripped me up was that if you have multiple projects included in your solution you need to make sure that they reference the same metapackage as if there is a version mismatch between projects included in your solution you will get this issue too.

    <PackageReference Include="Microsoft.AspNetCore.All" Version="2.2.5" />
    <PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="2.2.0" />
    <PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.2.0" />
    <PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.2.3" />

Changed to this.

    <PackageReference Include="Microsoft.AspNetCore.App" />
    <PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.2.0" PrivateAssets="All" />
    <PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.2.0" />

Solving Error: Package restore failed, AspNet Core, Error: Package restore failed. Rolling back package changes for 'App'. On the package Microsoft.AspNetCore.All, which means I cannot  Troubleshooting package restore errors. 05/25/2018; 5 minutes to read +3; In this article. This article focuses on common errors when restoring packages and steps to resolve them. Package Restore tries to install all package dependencies to the correct state matching the package references in your project file (.csproj) or your packages.config file.

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.

Package restore failed. Rolling back package changes · Issue , Try to downgrade a referenced package (e.g. Entity Framework from 6.2. to 6.1.3)​. Get error message "Package restore failed. Rolling back  Free source code and tutorials for Software developers and Architects.; Updated: 15 May 2019

Had exactly same problem, in my situation CodeGenerator was missing

I have added this item into ItemGroup in .csproj

<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.2.0" />

"Package restore failed. Rolling back package changes" appears , This error appears in the error list and it's frustrating that I can't get rid of it until after I build again. VS version 15.4.2. I have an existing .NET 4.5 project which uses packages.config Change to use package references using VS extension "NuGet PackageReference Upgraded" - looks good Try to downgrade a referenced package (e.g. Entity Frame

I was getting the same error while making a new controller. I've fixed it like this. Actually, VS only had the Offline Package source and could not resolve the packages needed.

Add the online reference: Tools > nuget package manager > package manager settings > Package Sources

Add source:

dotnet (ASPNETCORE) Package Restore Failed, problem: IDE reports errors in the output window concerning that the solution's project packages (pre-2.0.0 netcoreapp) could not be restored. fix: update all  NuGet Package restore failed for project Miscellaneous Files: Value cannot be null or an empty VS2013

Package restore failed. Rolling back package changes, Rolling back package changes" error. Many links suggest to clear cache of Nuget Package Manager which I did. I also restarted VS 2017 but that  In order to make package restore work for packages that have custom target files you have three options: Stop using package restore and check-in all package files; Explicitly run package restore before building the project; Check-in the .targets files; The first option isn’t a really an option and we certainly wouldn’t recommend it either. Core nuget, Core nuget - Package restore failed. Rolling back packages 07 October 2017 on, .netcore, core. I just had this error when updating a package  Automatic Package Restore will fail for any of the following reasons: You did not remove the NuGet.exe and NuGet.targets files from the solution's .nuget folder You did not enable automatic package restore from the Tools >> Options >> Nuget Package Manager >> You forgot to manually remove

NuGet Package Restore, At that time, NuGet reports a failure for only the last source in the list. The error implies that the package wasn't present on any of the other  Package Restore happens automatically when you create a project from a template or build a project, subject to the options in Enable and disable package restore. In NuGet 4.0+, restore also happens automatically when you make changes to a SDK-style project (typically a .NET Core or .NET Standard project).

  • Look at the Output pane, there must be more concrete info about the error.
  • Its shows nothing
  • Try to provide more details on the problem. Showing us just a image of the error won't get you much help...
  • I can't believe this has been marked as an answer, as it's simply unacceptable.
  • I agree this is a workaround not an answer, but it does work for me, whereas the other answer from Aamir does not work for me, and as noted error details from the scaffolding process do not appear in the Output window. I would love to hear the true answer, beginning with: Why should you never update NUGET packages, as stated by Anish?
  • That did the trick. dotnet restore didn't work, clearing the componentcache didn't work. Although I have to change back the PackageReferences after scaffolding because I'm getting some UI-exception (but it doesn't seem to affect the build)
  • have you included the CodeGeneration package?