[英]NuGet Package Manager attempting to add .NET 5.0 updates to .NET Core 3.1 application
When I go into Tools |当我进入工具| NuGet Package Manager |
NuGet 包管理器| Manage NuGet Package for Solution , it shows me there are 12 updates available.
管理解决方案的 NuGet 包,它显示我有 12 个可用更新。
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.我可以看到 .NET Core 3.1 和 .NET 5.0 之间存在不兼容问题,但我不知道为什么。
Why is NuGet Package Manager trying to add .NET 5.0 updates to a .NET Core 3.1 application?为什么 NuGet 包管理器试图将 .NET 5.0 更新添加到 .NET Core 3.1 应用程序?
Why is NuGet Package Manager trying to add .NET 5.0 updates to a .NET Core 3.1 application?
为什么 NuGet 包管理器试图将 .NET 5.0 更新添加到 .NET Core 3.1 应用程序?
.NET 5.0 is the next major release of .NET Core following 3.1. .NET 5.0 是 .NET Core 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.
.NET 5.0 发布后,我们可以通过 Nuget 包管理器安装 .NET 5.0 版本包,或者将现有的 ASP.NET Core 3.1 项目(和包)更新到 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:
因此,当我们打开 .Net Core 3.1 应用程序的 Nuget 包管理器时,我们将看到这些最新版本的更新:
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.
因为,目前我们的应用程序仍然面向 Asp.net Core 3.1 版本,而不是 .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.为了解决这个问题,你可以忽略这些更新,仍然使用 3.* 版本的 Asp.net Core 3.1 应用程序包。
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).否则,您可以将您的 ASP.NET Core 3.1 项目更新到 ASP.NET Core 5.0 (更新前,请确保您已安装 .NET 5.0 并将 Visual Studio 版本升级到最新版本)。
Right click the Project and click the Properties option, change the Target FrameWork from .NET Core 3.1 to .NET 5.0 .右键单击 Project 并单击Properties选项,将 Target FrameWork 从.NET Core 3.1更改为.NET 5.0 。 Save the change, then, click the Update button in the NuGet to update the packages.
保存更改,然后单击 NuGet 中的“更新”按钮以更新包。
[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.如果您使用 Visual Studio 2019 作为编辑器,请转到项目设置。
Application ----> Target framework -----> .NET 5.0应用程序----> 目标框架----> .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.
nuget 还原在 4.1 版的 Azure DevOps 上运行。 Bumping the nuget to version 5.8.1 did the trick.
将 nuget 升级到 5.8.1 版就成功了。
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.
在我的情况下,将我的 Visual Studio 更新到最新版本,然后将项目目标框架升级到 .NET 5.0 确实有效。
尝试安装 Install-Package Microsoft.Extensions.Primitives -Version 5.0.0,然后就可以安装 EF5。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.