[英]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
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.
您应该首先尝试删除所有bin和obj文件夹。
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 文件中删除了警告(即,我抑制了错误),但随后的下一个包列表开始抱怨同样的事情。
Deleting the bin/obj folders and cleaning the solution fixed the issue immediately.删除 bin/obj 文件夹并清理解决方案立即解决了问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.