Reputation: 67193
When I go into Tools | NuGet Package Manager | Manage NuGet Package for Solution, it shows me there are 12 updates available.
But when I attempt to update them all, I get errors.
NU1202: Package Microsoft.VisualStudio.Web.CodeGeneration 5.0.0 is not compatible with netcoreapp3.1 (.NETCoreApp,Version=v3.1). Package Microsoft.VisualStudio.Web.CodeGeneration 5.0.0 supports: net5.0 (.NETCoreApp,Version=v5.0)
NU1202: Package Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore 5.0.0 is not compatible with netcoreapp3.1 (.NETCoreApp,Version=v3.1). Package Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore 5.0.0 supports: net5.0 (.NETCoreApp,Version=v5.0)
NU1202: Package Microsoft.VisualStudio.Web.CodeGeneration.Utils 5.0.0 is not compatible with netcoreapp3.1 (.NETCoreApp,Version=v3.1). Package Microsoft.VisualStudio.Web.CodeGeneration.Utils 5.0.0 supports: net5.0 (.NETCoreApp,Version=v5.0)
NU1202: Package Microsoft.VisualStudio.Web.CodeGeneration.Contracts 5.0.0 is not compatible with netcoreapp3.1 (.NETCoreApp,Version=v3.1). Package Microsoft.VisualStudio.Web.CodeGeneration.Contracts 5.0.0 supports: net5.0 (.NETCoreApp,Version=v5.0)
NU1202: Package Microsoft.VisualStudio.Web.CodeGenerators.Mvc 5.0.0 is not compatible with netcoreapp3.1 (.NETCoreApp,Version=v3.1). Package Microsoft.VisualStudio.Web.CodeGenerators.Mvc 5.0.0 supports: net5.0 (.NETCoreApp,Version=v5.0)
Package restore failed. Rolling back package changes for 'SolutionName'.
I can see there are incompatibility issues between .NET Core 3.1 and .NET 5.0 but I don't know why.
Why is NuGet Package Manager trying to add .NET 5.0 updates to a .NET Core 3.1 application?
Upvotes: 15
Views: 38392
Reputation: 323
try install Install-Package Microsoft.Extensions.Primitives -Version 5.0.0, then you can install EF5.
Upvotes: 0
Reputation: 39
if you use visual studio 2019 as an editor go to project settings.
Application ----> Target framework -----> .NET 5.0
the problem will be solved.
Upvotes: 2
Reputation: 11
I encountered the same problem. In my case updating my visual studio to the latest version and then upgrading projects target framework to .NET 5.0 did work.
Upvotes: 1
Reputation: 81
In my case, downgrading to a previous version didn't work. The nuget restore was being run on Azure DevOps on version 4.1. Bumping the nuget to version 5.8.1 did the trick.
Upvotes: 3
Reputation: 21383
Why is NuGet Package Manager trying to add .NET 5.0 updates to a .NET Core 3.1 application?
.NET 5.0 is the next major release of .NET Core following 3.1. After the .NET 5.0 releasing, we could install the .NET 5.0 version packages via the Nuget Package Manager, Or update an existing ASP.NET Core 3.1 project (and the packages) to ASP.NET 5.0. So, when we open the .Net Core 3.1 application's Nuget Package Manager, we will see these Updates for the latest version:
Then, if we click the Update button to update these packages, it will show the not compatible error. Because, at present, our application is still targeted to the Asp.net Core 3.1 version, instead of .NET 5.0.
To solve this issue, you can ignore these Updates, and still using the 3.* version package for the Asp.net Core 3.1 application.
Otherwise, you can update an your ASP.NET Core 3.1 project to ASP.NET Core 5.0 (Before updating, please make sure you have installed .NET 5.0 and upgrade the Visual Studio version to the latest version).
Right click the Project and click the Properties option, change the Target FrameWork from .NET Core 3.1 to .NET 5.0. Save the change, then, click the Update button in the NuGet to update the packages.
[Note] When update the packages, please try to update them one by one (instead of Select all packages and click the Update button), because, they might contain dependencies.
Upvotes: 11