When I am trying to install any nuget package in VS2017 for asp.net core. it is constantly showing "Package restore failed. Rolling back package changes" for each package.
12 Answers
Try to install the appropriate version of the .net framework which you want to target.
Right click on your project, go to Properties, and then Install Other Frameworks.
This will take you to the TechNet download page for .netCore, download the appropriate SDK version here, install and then restart Visual Studio.
Now go back to Project Properties and pick the new Target Framework version and try again, it should work this time.
Interestingly, I faced the same problem in .net5 and Visual Studio 2019 v16.9.4, the code generation design package had a version of Microsoft.VisualStudio.Web.CodeGeneration.Design v5.0.2
.
After some digging I found out that scaffolding was trying to install a version of Microsoft.EntityFrameworkCore.SqlServer
that was older than the one I already depend on. Which was Microsoft.EntityFrameworkCore.SqlServer v5.0.5
so I downgraded its version to v5.0.4 and tried again after clearing nuget cache and it worked! After done scaffolding I then upgraded dependencies back to the desired version that I want.
Can you please specify which nuget package you are trying to install
As you have said you are getting the error
Package restore failed. 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.
The framework should be compatible with Microsoft.AspNetCore.All
For mine it said that i just had to change the version in my .csproj file to "4.5.0.530."
So, I went to the .csproj file, if you don't know how to do so check out this one minute video, and after following the steps, you should come to a page that look something like this.
Change your Version to "4.5.0.530" on the first line (I already did that, but it was originally something like "4.9":
<PackageReference Include="Xamarin.Forms" Version="4.5.0.530 />
Then you can save the .csproj file and reload the project. Try and re-install the plugin again.