سؤال

According to this question:

using nuget.exe commandline to install dependency

The command line NuGet tool does not follow dependencies intentionally. 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.

When specifying packages.config, only explicitly listed packages are installed.

However, if you try installing a specific package: nuget install My.Package.Id then NuGet will install the package and any dependencies.

EDIT Additional info as to why there's a distinction.

nuget install should really be called 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.

Since the true install updates packages.config, this file already includes all the dependencies that were installed. 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.

If you want to install/download multiple packages and have NuGet follow dependencies, just create a batch file and issue multiple commands:

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

This will cause NuGet to fetch the package an any dependencies it may have.

Hope this clarifies things.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top