visual-studio - NuGet忽略较新版本的依赖项

标签 visual-studio nuget nuget-package

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

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

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

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

有没有办法解决这个问题?

最佳答案

Is there any way to resolve this?



正如马特回答“这是 NuGet 的默认行为”:

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



所以 1.0 是一个正确的默认依赖解析。

NuGet v2.8 ,我们可以使用其他依赖解析算法:

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.



有关这些依赖解析算法的详细信息,请查看以下文档:

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

enter image description here

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

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

enter image description here

关于visual-studio - NuGet忽略较新版本的依赖项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46486983/

相关文章:

visual-studio-2010 - 在生产 Web 服务器上安装 Visual Studio 的原因

c# - 无法构建带有 project.json 的 .NET 项目

c# - 创建两个具有依赖关系的 Nuget 包

nuget - 使用 nuget 包转换 .csproj

asp.net-mvc - 更新 Bootstrap 后发生 "The build task could not find node.exe which is required to run the TypeScript compiler."

visual-studio - Xamarin.Android.Common.targets : error : Could not find a part of the path '/platforms'

ios - 无法在Xamarin Visual Studio中构建iOS应用

c++ - Visual C++ 团队测试问题

c# - 无法加载文件或程序集 Microsoft.Practices.ServiceLocation,版本 = 1.3.0.0

.net-core - dotnet core 的 nuget 可执行文件在哪里