简体   繁体   中英

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?

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.

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

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

the problem will be solved.

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.

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.

尝试安装 Install-Package Microsoft.Extensions.Primitives -Version 5.0.0,然后就可以安装 EF5。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM