how to get all nuget dependencies for offline installation

Colleen MacRay picture Colleen MacRay · Jul 13, 2014 · Viewed 16.6k times · Source

I two computers, one with internet connection and the other one without.

I want to install a Nuget package (Nuget.server) with all its dependencies on the offline computer. Unfortunately it is not possible just to download the package itself and I have to download all dependencies manually and there are dozens of them.

How can I create a package on the computer with internet connection that contains all dependencies?

Thanks.

Answer

Adrian Sanguineti picture Adrian Sanguineti · Apr 24, 2018

I just went through the pain of this and wanted to find a solution using only the NuGet CLI. Turns out it's pretty simple really:

> nuget.exe install <PACKAGENAME> -OutputDirectory <OUTPUTDIR>

The key is the -OutputDirectory switch which makes the CLI install the specified package into a directory that doesn't have a project file in it. Running this command will download the package and all of its dependencies into the output directory, with each package put into a separate sub-folder. You can then grab all of the .nupkg from the output directory and do whatever you need to do with them.

Update: As Igand points out in the comments, the -OutputDirectory switch is not actually required. If omitted nuget.exe will just download into the current folder. Still best to not download it into a folder with a project file in it (unless that is what you're after).