【问题标题】:Issue with Nuget package versions in .NET Core.NET Core 中的 Nuget 包版本问题
【发布时间】:2021-06-07 08:37:18
【问题描述】:

网络核心应用程序。我创建了一些名为 Authorization 的类库项目,它引用了

<PackageReference Include="Microsoft.Identity.Web" Version="1.10.0" />

然后我有另一个类库项目,我有参考

<PackageReference Include="Azure.Identity" Version="1.2.3" />

我已将这两个类库应用程序推送到 azure artifact 并在当前应用程序中使用它。当我尝试构建解决方案时,它给了我以下错误

RepositoryLayer.csproj :
 error NU1605: Detected package downgrade: Azure.Identity from 1.3.0 to 1.2.3. Reference the package directly from the project to select a different version. 
RepositoryLayer.csproj : 
     error NU1605:  RepositoryLayer -> Consume 1.1.46955 -> HttpClients 1.1.46955 -> 
     Authorisation 1.1.46955 -> Microsoft.Identity.Web 1.10.0 -> Azure.Identity (>= 1.3.0)
RepositoryLayer.csproj : 
     error NU1605:  RepositoryLayer -> Azure.Identity (>= 1.2.3)

已经花费了数小时来确定这一点,但无法理解根本原因。有人可以帮我确定这个问题。任何帮助,将不胜感激。谢谢

【问题讨论】:

  • 尝试删除对Microsoft.Identity.Web的引用
  • 您好 Hirasawa,我需要在我的应用程序中引用它。我可以知道可能是什么问题吗?
  • Microsoft.Identity.Web 已经包含对 Azure.Identity 的引用作为其依赖项之一。所以,不要同时使用这两个包。或者安装相同的版本。
  • Microsoft.Identity.Web 在一个类库应用程序中(作为 nuget 推送),Azure.Identity 在一个类库中(作为 nuget 推送)。现在我在我当前的 api 应用程序中使用这两个应用程序并导致问题。有没有办法解决这个问题?
  • 是的,安装 Azure.Identity 版本 1.3.0

标签: c# asp.net-core nuget nuget-package-restore


【解决方案1】:

三个步骤:

(1)使用最新版本

https://www.nuget.org/packages/Azure.Identity (1.4.0)

https://www.nuget.org/packages/Microsoft.Identity.Web (1.12.0)

(您应该使用 .NET 5 SDK 5.0.6 与 Azure.Identity 1.4.0Microsoft.Identity.Web 1.12.0 以确保兼容)

(2) 清理 Nuget 缓存,然后重新获取 nuget 包。

https://docs.microsoft.com/en-us/nuget/consume-packages/managing-the-global-packages-and-cache-folders#clearing-local-folders

您可以/应该删除文件夹packages 中的所有旧内容以清除所有旧内容。我要确保不存在损坏的文件。

(3) 删除binobj,重新构建项目。

让我们分享你的结果。

【讨论】:

  • 感谢您的回答。但是我使用的是 .Net core 3.1,所以我应该使用 azure.identity 1.3.0 对吗? microsoft.identity.web 我应该使用哪个版本呢?让我在这里清理并张贴我的 cmets 非常感谢
  • 是的,它受 .NET Core 3.1 支持。请参阅 nuget.org/packages/Azure.Identity/1.4.0 ,选择 Dependencies 部分。
猜你喜欢
  • 2020-08-07
  • 2021-07-31
  • 1970-01-01
  • 2020-05-14
  • 2018-10-22
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-06-20
相关资源
最近更新 更多