ASP.NET Core Web API - 如何解决在依赖约束之外检测到的包版本
ASP.NET Core Web API - How to resolve Detected package version outside of dependency constraint
在我的 ASP.NET Core-6 Web API 中,当我尝试安装时:
Install-Package AutoMapper.Extensions.Microsoft.DependencyInjection -Version 11.0.0
通过 Nugget 包,我得到了这个错误:
Detected package version outside of dependency constraint: Duende.IdentityServer.EntityFramework.Storage 5.2.0 requires AutoMapper (>= 10.0.0 && < 11.0.0) but version AutoMapper 11.0.1 was resolved.
在尝试解决它时,我安装了 AutoMapper ver-11.0.1
然后应用程序标记了已安装的 AutoMapper。
我该如何解决?
谢谢
TLDR:将 AutoMapper.Extensions.Microsoft.DependencyInjection
降级为 8.1.1
取决于 AutoMapper (>= 10.1.1 && < 11.0.0)
https://www.nuget.org/packages/AutoMapper.Extensions.Microsoft.DependencyInjection/8.1.1
长答案:
我也收到了类似的警告或错误,但对我来说是在安装 NuGet 时 AutoMapper
:
NU1608 Detected package version outside of dependency constraint:
Duende.IdentityServer.EntityFramework.Storage 5.2.0 requires
AutoMapper (>= 10.0.0 && < 11.0.0) but version AutoMapper 11.0.1 was
resolved.
您可能安装了 NuGet Microsoft.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.存储 (>= 5.2.0)
- Duende.IdentityServer.存储 (>= 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.存储
- Duende.IdentityServer.存储
Duende.IdentityServer.EntityFramework.Storage 6.1.0 具有以下依赖项,可修复您的错误:
- net6.0
- AutoMapper (>= 11.0.0 && < 12.0.0)
- Duende.IdentityServer.存储(>=6.1.0)
- Microsoft.EntityFrameworkCore.Relational (>= 6.0.0)
https://www.nuget.org/packages/Duende.IdentityServer.EntityFramework.Storage/
然而,当 运行 您的代码用于 endpoints.MapRazorPages();
时,这可能会给您这个例外。
System.Reflection.ReflectionTypeLoadException: 'Unable to load one or
more of the requested types. Method 'get_ServerSideSessions' in type
'Microsoft.AspNetCore.ApiAuthorization.IdentityServer.ApiAuthorizationDbContext`1'
from assembly 'Microsoft.AspNetCore.ApiAuthorization.IdentityServer,
Version=6.0.5.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'
does not have an implementation.'
我已要求 Microsoft 更新 Microsoft.AspNetCore.ApiAuthorization.IdentityServer
,使其与最新的 Duende.IdentityServer.EntityFramework.Storage
兼容,这将解决问题。
在我的 ASP.NET Core-6 Web API 中,当我尝试安装时:
Install-Package AutoMapper.Extensions.Microsoft.DependencyInjection -Version 11.0.0
通过 Nugget 包,我得到了这个错误:
Detected package version outside of dependency constraint: Duende.IdentityServer.EntityFramework.Storage 5.2.0 requires AutoMapper (>= 10.0.0 && < 11.0.0) but version AutoMapper 11.0.1 was resolved.
在尝试解决它时,我安装了 AutoMapper ver-11.0.1
然后应用程序标记了已安装的 AutoMapper。
我该如何解决?
谢谢
TLDR:将 AutoMapper.Extensions.Microsoft.DependencyInjection
降级为 8.1.1
取决于 AutoMapper (>= 10.1.1 && < 11.0.0)
https://www.nuget.org/packages/AutoMapper.Extensions.Microsoft.DependencyInjection/8.1.1
长答案:
我也收到了类似的警告或错误,但对我来说是在安装 NuGet 时 AutoMapper
:
NU1608 Detected package version outside of dependency constraint: Duende.IdentityServer.EntityFramework.Storage 5.2.0 requires AutoMapper (>= 10.0.0 && < 11.0.0) but version AutoMapper 11.0.1 was resolved.
您可能安装了 NuGet Microsoft.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.存储 (>= 5.2.0)
- Duende.IdentityServer.存储 (>= 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.存储
- Duende.IdentityServer.存储
Duende.IdentityServer.EntityFramework.Storage 6.1.0 具有以下依赖项,可修复您的错误:
- net6.0
- AutoMapper (>= 11.0.0 && < 12.0.0)
- Duende.IdentityServer.存储(>=6.1.0)
- Microsoft.EntityFrameworkCore.Relational (>= 6.0.0)
https://www.nuget.org/packages/Duende.IdentityServer.EntityFramework.Storage/
然而,当 运行 您的代码用于 endpoints.MapRazorPages();
时,这可能会给您这个例外。
System.Reflection.ReflectionTypeLoadException: 'Unable to load one or more of the requested types. Method 'get_ServerSideSessions' in type 'Microsoft.AspNetCore.ApiAuthorization.IdentityServer.ApiAuthorizationDbContext`1' from assembly 'Microsoft.AspNetCore.ApiAuthorization.IdentityServer, Version=6.0.5.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' does not have an implementation.'
我已要求 Microsoft 更新 Microsoft.AspNetCore.ApiAuthorization.IdentityServer
,使其与最新的 Duende.IdentityServer.EntityFramework.Storage
兼容,这将解决问题。