ASP.NET Core Web API - 如何解析依赖约束之外检测到的包版本

Ayo*_*aye 5 c# nuget-package asp.net-web-api

在我的 ASP.NET Core-6 Web API 中,当我尝试安装时:

安装包 AutoMapper.Extensions.Microsoft.DependencyInjection -版本 11.0.0

通过 Nugget 包,我收到此错误:

检测到的软件包版本超出依赖性约束:Duende.IdentityServer.EntityFramework.Storage 5.2.0 需要 AutoMapper (>= 10.0.0 && < 11.0.0),但版本 AutoMapper 11.0.1 已解决。

在尝试解决它时,我安装了 AutoMapper ver-11.0.1

然后应用程序标记已安装的 AutoMapper。

我该如何解决这个问题?

谢谢

Ogg*_*las 9

TLDR:降级AutoMapper.Extensions.Microsoft.DependencyInjection取决于8.1.1AutoMapper (>= 10.1.1 && < 11.0.0)

https://www.nuget.org/packages/AutoMapper.Extensions.Microsoft.DependencyInjection/8.1.1

长答案:

我也收到类似的警告或错误,但对我来说是在安装 NuGet 时AutoMapper

NU1608 检测到的软件包版本超出依赖性约束:Duende.IdentityServer.EntityFramework.Storage 5.2.0 需要 AutoMapper (>= 10.0.0 && < 11.0.0),但版本 AutoMapper 11.0.1 已解决。

您可能安装了 NuGetMicrosoft.AspNetCore.ApiAuthorization.IdentityServer或类似软件。

https://www.nuget.org/packages/Microsoft.AspNetCore.ApiAuthorization.IdentityServer

如果您查看 Microsoft.AspNetCore.ApiAuthorization.IdentityServer NuGet 依赖项,您将看到:

  • .net6.0
  • Duende.IdentityServer (>= 5.2.0)
  • Duende.IdentityServer.AspNetIdentity (>= 5.2.0)
  • Duende.IdentityServer.EntityFramework (>= 5.2.0)
  • Duende.IdentityServer.EntityFramework.Storage (>= 5.2.0)
  • Duende.IdentityServer.Storage (>= 5.2.0)
  • Microsoft.AspNetCore.Authentication.JwtBearer (>= 6.0.5)
  • Microsoft.AspNetCore.Identity.EntityFrameworkCore (>= 6.0.5)
  • Microsoft.AspNetCore.Identity.UI (>= 6.0.5)
  • Microsoft.Extensions.Http (>= 6.0.0)
  • Newtonsoft.Json (>= 13.0.1)

您可以通过手动更新以下库来解决该问题:

  • Duende.IdentityServer
  • Duende.IdentityServer.AspNetIdentity
  • Duende.IdentityServer.EntityFramework
  • Duende.IdentityServer.EntityFramework.Storage
  • Duende.IdentityServer.Storage

Duende.IdentityServer.EntityFramework.Storage 6.1.0 具有以下依赖项,可以修复您的错误:

  • .net6.0
  • 自动映射器 (>= 11.0.0 && < 12.0.0)
  • Duende.IdentityServer.Storage (>= 6.1.0)
  • Microsoft.EntityFrameworkCore.Relational (>= 6.0.0)

https://www.nuget.org/packages/Duende.IdentityServer.EntityFramework.Storage/

然而,在运行endpoints.MapRazorPages();.

System.Reflection.ReflectionTypeLoadException:“无法加载一种或多种请求的类型。程序集“Microsoft.AspNetCore.ApiAuthorization.IdentityServer,Version=6.0.5.0,Culture=neutral,PublicKeyToken=adb9793829ddae60”中类型“Microsoft.AspNetCore.ApiAuthorization.IdentityServer.ApiAuthorizationDbContext`1”中的方法“get_ServerSideSessions”没有实现。 '

我已要求微软进行更新,Microsoft.AspNetCore.ApiAuthorization.IdentityServer使其与最新版本兼容Duende.IdentityServer.EntityFramework.Storage,从而解决该问题。

https://github.com/dotnet/aspnetcore/issues/41897