Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NuGet Package Manager attempting to add .NET 5.0 updates to .NET Core 3.1 application

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?

like image 736
Jonathan Wood Avatar asked Nov 23 '20 21:11

Jonathan Wood


People also ask

Is .NET Core 3.1 supported?

NET Core 3.1 was originally released on December 3, 2019 and is supported for three years. But the actual end of support day will be the closest Patch Tuesday starting that date, which is December 13, 2022.

How do I force a NuGet package to Install?

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.

Does .NET core use NuGet?

NET (including . NET Core), the Microsoft-supported mechanism for sharing code is NuGet, which defines how packages for .

How do I force a NuGet package to uninstall?

Right-click on Project and select Manage NuGet Packages option. Select the Installed tab from NuGet Package Manager dialog and you can see the installed Syncfusion NuGet packages list by giving the Syncfusion keyword in search. Uninstall the Syncfusion NuGet packages which are not required for the project.


2 Answers

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:

enter image description here

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.

enter image description here

[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.

like image 97
Zhi Lv Avatar answered Oct 02 '22 15:10

Zhi Lv


if you use visual studio 2019 as an editor go to project settings.

Application ----> Target framework -----> .NET 5.0

the problem will be solved.

like image 41
OrkunPinarkaya Avatar answered Oct 02 '22 17:10

OrkunPinarkaya