NuGet忽略较新版本的依赖项 [英] NuGet ignoring newer version of dependency

查看:32
本文介绍了NuGet忽略较新版本的依赖项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个 NuGet 包.套餐一,套餐二.包二需要依赖包一版本 1.0 或更高版本.

我对 Package One 做了一个小改动,并将 NuGet Package 重新构建到 1.0.1 版本.我没有对 Package Two NuGet 包进行任何更改.我还在我正在使用的解决方案中更新了 Package One.

我遇到的问题是包二仍在尝试查找版本 1.0(旧版本)的包一的 .dll.但是已经安装了新版本可以使用了,就好像忽略了一样.

包二在package.nuspec文件中依赖包一的1.0或更高版本.

有什么办法可以解决这个问题吗?

解决方案

有什么办法可以解决这个问题吗?

正如 Matt 回答这是 NuGet 的默认行为":

<块引用>

对于 NuGet 2.5 及更高版本,如果已满足依赖项版本,则在其他包安装期间不会更新该依赖项.

所以 1.0 是正确的默认依赖项解析.

由于

要解决此问题,您可以在包管理器控制台中使用以下命令:

Install-Package PackageTwo -DependencyVersion 最高

或者通过展开选项从管理 NuGet 包 UI 中选择它:

I have two NuGet Packages. Package One, and package Two. Package Two needs to have an dependency as Package One version 1.0 or higher.

I have made a small change to Package One and re-built the NuGet Package to the version of 1.0.1. I have not made any changes to the Package Two NuGet package. I have also updated Package One in the solution I am working in.

The issue I am having is that Package Two is still trying to look for the .dll of Package One of version 1.0, an old version. Yet there is the newer version already installed and available to use, it is like it is ignoring it.

Package Two has the dependency of version 1.0 or higher of Package One in the package.nuspec file.

Is there any way to resolve this?

解决方案

Is there any way to resolve this?

Just as Matt answered "This is the default behaviour of NuGet":

With NuGet 2.5 and later, if a dependency version is already satisfied, the dependency isn't updated during other package installations.

So 1.0 is a correct default dependency resolution.

Since NuGet v2.8, we could use other dependency resolution algorithms:

Though NuGet 2.8 changes the default behavior for resolving dependencies, it also adds more precise control over dependency resolution process via the -DependencyVersion switch in the package manager console. The switch enables resolving dependencies to the lowest possible version (default behavior), the highest possible version, or the highest minor or patch version.

The detail information about the those dependency resolution algorithms, please check below document:

https://docs.microsoft.com/en-us/nuget/tools/ps-ref-install-package

To resolve this issue, you can use below command in the Package Manager Console:

Install-Package PackageTwo -DependencyVersion Highest

Or chose it from Manage NuGet package UI by expending Options:

这篇关于NuGet忽略较新版本的依赖项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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