【发布时间】:2021-03-13 19:00:10
【问题描述】:
我正在从 .Net Core 3.1 迁移到 .NET 5.0。
我不断收到此错误消息:
包 Microsoft.AspNetCore.Authentication.JwtBearer 5.0.0 与 netcoreapp3.1 (.NETCoreApp,Version=v3.1) / win-x86 不兼容。包 Microsoft.AspNetCore.Authentication.JwtBearer 5.0.0 支持:net5.0 (.NETCoreApp,Version=v5.0)
我明白它在说什么,但我不知道它为什么这么说。
我的项目面向 .NET 5.0。
我的 csproj 文件如下所示:
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<UserSecretsId>5e2f8086-7a94-402a-bd2a-4160e9236c8f</UserSecretsId>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Authentication" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="5.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Abstractions" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Formatters.Json" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="5.0.0" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="5.0.0" />
</ItemGroup>
</Project>
我不确定它为什么告诉我 3.1。
我手动删除了 bin 和 obj 文件夹,尝试更新所有 nuget 包,并清理/重建项目,但每次都遇到相同的问题。v
我使用的是 Visual Studio 16.8.2。
编辑
我要指出,这个错误不是编译器错误!如果我在 Visual Studio 中进行调试,网站会正常运行。此错误消息仅在我尝试发布时出现
【问题讨论】:
标签: asp.net-core asp.net-core-3.1 asp.net-core-5.0