2

I'm using NuGet CLI tool to manage package dependencies in a non-VisualStudio environment. Is there a way to use the packages.config file with the command install and get all dependencies that the listed dependencies in the packages.config file have? The whole dependency graph.

Example: My packages.config lists one dependency A. The A package has a dependency B.

If I run nuget install packages.config I only get package A.

If I run nuget install A I also get B.

I'm afraid I have to write a script to read the packages.config, looping through all dependencies calling install for each, to make this work.

Are there any other possibilities just using the CLI tool?

Jan Lovstrand
  • 228
  • 2
  • 9
  • Have you tried [`nuget restore [options]`](https://learn.microsoft.com/en-us/nuget/tools/cli-ref-restore#usage)? Since you already have the packages.config file, it seems like a restore would work for you. – techvice Dec 19 '17 at 22:58
  • @techvice Because of the fact that my packages.config file only contains direct dependencies, the restore command works exactly as `nuget install packages.config`, thus not download/unpack the dependency B. – Jan Lovstrand Dec 20 '17 at 07:19
  • Using the latest NuGet (v4.4.1), when I run the command `nuget install xunit`, it will not only install xunit but all of the dependencies. Are you using the latest version of [NuGet](https://dist.nuget.org/win-x86-commandline/latest/nuget.exe)? – techvice Dec 20 '17 at 14:52
  • @techvice Yes I am, and I know that install with one package works, but want one command that gets one file as input with only the direct dependencies that gets all sub-dependencies. – Jan Lovstrand Dec 20 '17 at 18:17
  • @JanLovstrand, did you ever figure this out? I had the exact same expectation. I'm at version 4.9.4 and it still has this behavior, so I'm guessing it's how they intend it to operate. – Craig Jul 10 '19 at 20:52
  • @Craig I had to do as I stated. Read the read out the dependencies and call install for each one of them. – Jan Lovstrand Jul 12 '19 at 06:11

0 Answers0