MyD*_*ons 5 asp.net-core asp.net-core-3.1 asp.net-core-5.0
我正在从 .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>
Run Code Online (Sandbox Code Playgroud)
我不确定为什么它会告诉我 3.1。
我手动删除了 bin 和 obj 文件夹,尝试更新所有 nuget 包,并清理/重建项目,但我每次都遇到相同的问题。
我在 Visual Studio 16.8.2 上。
编辑
我应该指出,该错误不是编译器错误!如果我在 Visual Studio 中进行调试,网站就会正常运行。此错误消息仅在我尝试发布时出现
如果您尚未升级到 5,您可以通过单击 nuget 中的版本下拉列表来安装 microsoft.aspnetcore.authentication.jwtbearer 版本 3.1.x。
| 归档时间: |
|
| 查看次数: |
9792 次 |
| 最近记录: |