简体   繁体   English

检测到 NuGet 包的版本冲突

[英]Version conflict detected for NuGet packages

I am working on an ASP.Net core 2.1 web app project.我正在研究 ASP.Net 核心 2.1 Web 应用程序项目。 I have 1 project in my solution and 3 other libraries, it's and advanced architecture (data access layer ( DAL ), business layer ( BL ), common layer ( CL )), so i need to add references to connect some libraries and project.我的解决方案中有 1 个项目和其他 3 个库,它是高级架构(数据访问层( DAL )、业务层( BL )、公共层( CL )),所以我需要添加引用来连接一些库和项目。 I have added CL reference to my project and to libraries DAL and BL .我已将CL引用添加到我的项目以及库DALBL Now I have to add reference BL to my project, but when I add I get this type of error:现在我必须将引用BL添加到我的项目中,但是当我添加时,我得到了这种类型的错误:

Version conflict detected fr Microsoft.EntityFrameworkCore/ Install/reference Microsoft.EntityFrameworkCore 2.2.1 directly to project 'WEB' to resolve this issue检测到版本冲突从 Microsoft.EntityFrameworkCore/ 安装/引用 Microsoft.EntityFrameworkCore 2.2.1 直接到项目 'WEB' 以解决此问题

When I am trying to install that version it says当我尝试安装该版本时,它说

Package restore failed.包还原失败。 Rolling back package changes for 'WEB'回滚“WEB”的包更改

I can also mention that when I add reference BL to my project, it also includes DAL , and CL itself, (and DAL contains Microsoft.EntityFrameworkCore (2.2.1), can't understand what's the problem, any ideas?我还可以提到,当我向我的项目添加引用BL ,它还包括DALCL本身,(并且DAL包含Microsoft.EntityFrameworkCore (2.2.1),无法理解是什么问题,有什么想法吗?

Additional Images of the problem in here .此处问题的其他图像。

project.csproj项目.csproj

<Project Sdk="Microsoft.NET.Sdk.Web">
  <PropertyGroup>
    <TargetFramework>netcoreapp2.1</TargetFramework>
    <AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.App" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\CL\CL.csproj" />
</ItemGroup>

</Project>

i have added CL reference as you can see, now i want to add BL reference and get this error如您所见,我已添加CL引用,现在我想添加BL引用并收到此错误

The issue is because you're having local directory path to one of your {projectName}.csproj file Kindly review your .csproj files by Right clicking project and select Edit {projectName}.scproj问题是因为您拥有 {projectName}.csproj 文件之一的本地目录路径请通过右键单击项目并选择 Edit {projectName}.scproj 查看您的 .csproj 文件

eg例如

<Reference Include="Microsoft.EntityFrameworkCore">
      <HintPath>..\..\..\..\..\..\..\Program Files\dotnet\sdk\NuGetFallbackFolder\Microsoft.EntityFrameworkCore\2.1.1\lib\netstandard2.0\Microsoft.EntityFrameworkCore.dll</HintPath>
    </Reference>

If yes than go to Nuget Package Manager and add your library bu selecting nuget.org as Package Source如果是,则转到 Nuget 包管理器并添加您的库 bu 选择 nuget.org 作为包源

after restoring from nuget Package manager csproject file will have following tag Added to从 nuget 包管理器 csproject 文件恢复后,将添加以下标签

<PackageReference Include="Microsoft.Extensions.Identity.Stores" Version="2.1.1" />

Here {projectName} is the name of C# project.这里的 {projectName} 是 C# 项目的名称。

Just want to chip in that i had the same issue but with EntityFrameworkCore 3.0 preview.只是想说明我有同样的问题,但使用 EntityFrameworkCore 3.0 预览版。 I solved it by simply downgrading all entityframework 3.0(preview) nuget packages to latest stable (2.2).我通过简单地将所有 entityframework 3.0(预览版)nuget 包降级到最新的稳定版(2.2)来解决它。

Hopefully this helps someone aswell, took me hours...希望这对某人也有帮助,花了我几个小时......

Option 1 check visual studio error window and identify which package is making the conflict .选项 1 检查 Visual Studio 错误窗口并确定导致冲突的包。 make sure both packages have save version code确保两个包都有保存版本代码

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM