简体   繁体   English

从.NET Core 2.1迁移到.NET Core 3.1后,publish出现问题

[英]After migrating from .NET Core 2.1 to .NET Core 3.1, publish has a problem

After migrating my project from .NET Core 2.1 to .NET Core 3.1, everything works fine but when publishing the project, Iget this error:将我的项目从 .NET Core 2.1 迁移到 .NET Core 3.1 后,一切正常,但在发布项目时,出现此错误:

System.Runtime.CompilerServices.Unsafe doesn't support netcoreapp3.1. System.Runtime.CompilerServices.Unsafe 不支持 netcoreapp3.1。 Consider updating your TargetFramework to netcoreapp3.1 or later.考虑将 TargetFramework 更新到 netcoreapp3.1 或更高版本。

@@Morteza install System.Runtime.CompilerServices.Unsafe version 6.0.0 from NuGet into your project. @@Morteza 将 System.Runtime.CompilerServices.Unsafe 版本 6.0.0 从 NuGet 安装到您的项目中。

Install-Package System.Runtime.CompilerServices.Unsafe -Version 6.0.0

I resolved the problem after remove the tag <RuntimeIdentifier> from the publish profile.从发布配置文件中删除标签<RuntimeIdentifier>后,我解决了问题。

The root cause of the issue for me is, one of the NuGet packages is referring to "Microsoft.Extensions.DependencyModel" v6.0.0 .对我来说,问题的根本原因是,其中一个 NuGet 包指的是"Microsoft.Extensions.DependencyModel" v6.0.0 After downgrading the "Microsoft.Extensions.DependencyModel" NuGet to version 5.0.0 issue is resolved."Microsoft.Extensions.DependencyModel"降级到版本 5.0.0 后,NuGet 问题得到解决。

Please refer to the link for more info, https://github.com/dotnet/runtime/issues/62561请参阅链接以获取更多信息, https://github.com/dotnet/runtime/issues/62561

Try this first!先试试这个!

For anyone suddenly running into this error for seemingly no reason, the error message may be a red herring.对于任何突然无缘无故遇到此错误的人来说,错误消息可能是一个转移注意力的问题。 You should try deleting all bin and obj folders first before anything else.您应该首先尝试删除所有binobj文件夹。

  1. For each project in your solution, locate and delete the obj and bin folders (don't worry, they will be regenerated automatically).对于解决方案中的每个项目,找到并删除 obj 和 bin 文件夹(不用担心,它们会自动重新生成)。
  2. Right-click the solution and click "Clean Solution"右键单击该解决方案,然后单击“清理解决方案”
  3. Right-click your startup project and click "Rebuild"右键单击您的启动项目,然后单击“重建”

For me, the problem occurred while attempting to publish, even though (a) no changes had taken place, (b) it worked the day before, and (c) I was actually using .NET 6.0!对我来说,问题发生在尝试发布时,即使 (a) 没有发生任何更改,(b) 它在前一天工作,并且 (c) 我实际上使用的是 .NET 6.0!

After failing to fix the issue through any recommended solutions, I went ahead and actually removed the warning from the.targets file in the System.Runtime.CompilerServices.Unsafe package folder (ie, I suppressed the error), but then the next package in the list started complaining about the same thing.在无法通过任何推荐的解决方案解决问题后,我继续并实际上从System.Runtime.CompilerServices.Unsafe包文件夹中的 .targets 文件中删除了警告(即,我抑制了错误),但随后的下一个包列表开始抱怨同样的事情。

Solution解决方案

Deleting the bin/obj folders and cleaning the solution fixed the issue immediately.删除 bin/obj 文件夹并清理解决方案立即解决了问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 从.Net Core 3.1 迁移到 .NET 5 - Migrating from .Net Core 3.1 to .NET 5 将 .net 内核从 2.1 升级到 3.1 后测试无法运行 - Tests fail to run after upgrading .net core from 2.1 to 3.1 从 2.1 迁移到 3.1.Net Core,Microsoft.AspNetCore.App 的替代品是什么? - Migrating from 2.1 to 3.1 .Net Core, What is the Replacement of Microsoft.AspNetCore.App? 从 .NET Core 2.2 迁移到 3.1 后,不会在 ASP.NET Core 自定义 AuthenticationHandler 中忽略 AllowAnonymous - AllowAnonymous is not ignored in ASP.NET Core custom AuthenticationHandler after migrating from .NET Core 2.2 to 3.1 从 .NET Core 2.1 更新后的 EF.Core 3.1 复合主/外键问题 - EF .Core 3.1 composite primary / foreign key problems after update from .NET Core 2.1 迁移到 .Net Core v3.1 后 IAsyncQueryProvider 构建错误 - IAsyncQueryProvider build errors after migrating to .Net Core v3.1 从 2.2 迁移到 3.1 后 EF Core 的问题 - Problem with EF Core after migrating from 2.2 to 3.1 迁移到 .NET Core 2.1 打破了 Swagger UI - Migrating to .NET Core 2.1 breaks Swagger UI 从 ASP.NET CORE 3.0 迁移到 3.1 - Migrating from ASP.NET CORE 3.0 to 3.1 从 .NET core 2.2 迁移到 3.1 api 后,将 newtonsoft 添加到项目时,结果中间件中断 - After migrating to from .NET core 2.2 to 3.1 api result middleware breaks when adding newtonsoft to project
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM