简体   繁体   English

为什么nuget命令行工具不遵循依赖关系?

[英]Why does the nuget command line tool not follow dependencies?

According to this question: 根据这个问题:

using nuget.exe commandline to install dependency 使用nuget.exe命令行安装依赖项

The command line NuGet tool does not follow dependencies intentionally. 命令行NuGet工具不会故意遵循依赖关系。 While I could understand this as the default behavior, it seems odd to me that there is no choice to have the tool follow the dependencies. 虽然我可以将其理解为默认行为,但对我来说似乎很奇怪,没有选择让该工具遵循依赖关系。 Is anyone aware of the reasoning behind this? 有人知道这背后的原因吗?

That answer is specific to running nuget install packages.config . 这个答案是特定于运行nuget install packages.config

When specifying packages.config , only explicitly listed packages are installed. 指定packages.config时 ,仅安装明确列出的软件包。

However, if you try installing a specific package: nuget install My.Package.Id then NuGet will install the package and any dependencies. 但是,如果尝试安装特定的软件包: nuget install My.Package.Id则NuGet将安装该软件包和所有依赖项。

EDIT Additional info as to why there's a distinction. 编辑有关为何有区别的其他信息。

nuget install should really be called nuget download . nuget install实际上应该称为nuget download It doesn't really install in the traditional sense. 它并不是真正意义上的传统安装 That is, it doesn't add references to your project files, it doesn't run install.ps1 , it doesn't update packages.config , etc. You need to either use the NuGet GUI or Package Manager console to get a true install. 也就是说,它不会添加对项目文件的引用,不会运行install.ps1 ,不会更新packages.config等。您需要使用NuGet GUI或Package Manager控制台来获取真实的安装。

Since the true install updates packages.config , this file already includes all the dependencies that were installed. 由于真正的安装会更新packages.config ,因此该文件已包含所有已安装的依赖项。 So specifying the file means, I want to download these specific packages. 因此,指定文件意味着我要下载这些特定的软件包。 NuGet doesn't need to think about it since it's basically pre-calculated . NuGet不需要考虑它,因为它基本上是预先计算的

If you want to install/download multiple packages and have NuGet follow dependencies, just create a batch file and issue multiple commands: 如果要安装/下载多个软件包并让NuGet遵循依赖关系,只需创建一个批处理文件并发出多个命令:

nuget install My.Package.Id
nuget install Another.Package.Id

This will cause NuGet to fetch the package an any dependencies it may have. 这将导致NuGet获取包可能具有的任何依赖关系。

Hope this clarifies things. 希望这可以澄清事情。

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

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