检测到NuGet软件包的版本冲突 [英] Version conflict detected for NuGet packages

查看:233
本文介绍了检测到NuGet软件包的版本冲突的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究ASP.Net核心2.1 Web应用程序项目.我的解决方案中有1个项目,还有其他3个库,它是高级架构(数据访问层(DAL),业务层(BL),公共层(CL)),因此我需要添加对连接一些库和项目.我已经在项目和库DALBL中添加了CL引用.现在我必须将引用BL添加到我的项目中,但是当我添加时会出现这种错误:

I am working on an ASP.Net core 2.1 web app project. 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. I have added CL reference to my project and to libraries DAL and BL. Now I have to add reference BL to my project, but when I add I get this type of error:

从Microsoft.EntityFrameworkCore/检测到版本冲突/直接将Microsoft.EntityFrameworkCore 2.2.1安装/引用到项目"WEB"以解决此问题

Version conflict detected fr Microsoft.EntityFrameworkCore/ Install/reference Microsoft.EntityFrameworkCore 2.2.1 directly to project 'WEB' to resolve this issue

当我尝试安装该版本时,它会显示

When I am trying to install that version it says

打包还原失败.回滚"WEB"的软件包更改

Package restore failed. Rolling back package changes for 'WEB'

我还可以提到,当我在项目中添加引用BL时,它还包含DALCL本身(并且DAL包含Microsoft.EntityFrameworkCore(2.2.1),不能明白问题出在哪里,有什么主意吗?

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?

此问题的其他图片 https://imgur.com/a/rtjfP1i

project.csproj

project.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>

我已经添加了CL参考,如您所见,现在我想添加BL参考并得到此错误

i have added CL reference as you can see, now i want to add BL reference and get this error

推荐答案

问题是因为您具有{projectName} .csproj文件之一的本地目录路径 右键单击项目,查看.csproj文件,然后选择Edit {projectName} .scproj

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

例如

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

如果可以,请转到Nuget软件包管理器,然后选择nuget.org作为软件包源,添加您的库

If yes than go to Nuget Package Manager and add your library bu selecting nuget.org as Package Source

将添加以下标签 到

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

此处{projectName}是C#项目的名称.

Here {projectName} is the name of C# project.

这篇关于检测到NuGet软件包的版本冲突的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆