简体   繁体   English

强制 Nuget 包使用特定版本的子依赖项?

[英]Force Nuget package to use specific version of sub dependency?

When installing the two Nuget packages Hl7.Fhir.DSTU2 and Hl7.Fhir.R4, we get something like this:安装两个 Nuget 包 Hl7.Fhir.DSTU2 和 Hl7.Fhir.R4 时,我们得到如下内容:

在此处输入图片说明

The package DSTU2 seems to have issues using Hl7.Fhir.Support.Poco version 3.4.0. DSTU2 软件包在使用 Hl7.Fhir.Support.Poco 3.4.0 版时似乎存在问题。 If we install DSTU2 on it's own, all packages are using the version 1.9.0.如果我们自己安装 DSTU2,则所有软件包都使用 1.9.0 版本。

Is there a way in the .csproj file to specify sub dependencies versions and have the .dll installed in specific folders? .csproj 文件中是否可以指定子依赖项版本并将 .dll 安装在特定文件夹中?

Here are the 3.4.0 versions .dll in my debug folder这是我的调试文件夹中的 3.4.0 版本 .dll

在此处输入图片说明

Yes, you just add a PackageReference in your project for the transitive dependency as well.是的,您只需在项目中为传递依赖添加一个PackageReference NuGet picks a single version to use for each package you depend on, and if you have a direct reference to a package then NuGet will always pick this version due to its nearest wins rule . NuGet 为您依赖的每个包选择一个版本,如果您直接引用一个包,那么 NuGet 将始终选择该版本,因为它最接近 wins rule

As you've spotted though, this can't be a lower version than any of your dependencies require themselves, or you get a package downgrade error .但是,正如您所发现的,这不能是比您的任何依赖项本身要求的更低的版本,否则您会收到包降级错误 This is intentional - if you reference packageA which says it needs at least a particular version of packageB , then given that you can only use one version of each package it stands to reason that you need at least that version of packageB .这是故意的 - 如果您引用packageA ,它说它至少需要一个特定版本的packageB ,那么鉴于您只能使用每个包的一个版本,所以您至少需要那个版本的packageBpackageB

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

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