23

I downloaded nuget.exe and I have tried the install. I would like to target a Visual Studio project so it adds a reference on the command line outside of Visual Studio. It is simply downloading the package with a version number on the end. MyOutputDirectory is the output directory which has a Visual studio solution there.

nuget install nhibernate -o MyOutputDirectory
Peter Mortensen
  • 28,342
  • 21
  • 95
  • 123
Greg Finzer
  • 5,959
  • 18
  • 69
  • 113

2 Answers2

21

The NuGet Command Line does not actually install any packages. The install command is actually doing a restore operation.

This means that nuget.exe install will only download and extract the package into the output location. It will not modify the project file (so no references are added, no content files injected, no transformations applied, no MSBuild files imported), and it will also not run any PowerShell scripts.

I do believe that a similar request to yours is being tracked by the NuGet team, but feel free to log an issue there: http://nuget.codeplex.com.

To answer your question: the NuGet Command Line does not support your scenario at this moment (nuget.exe v2.8).

Xavier Decoster
  • 14,182
  • 4
  • 33
  • 45
19

Well, it's not command line per se, but you can do this through the Package Manager Console in Visual Studio (accessed via Tools > Library Package Manager > Package Manager Console). When installing a package to multiple projects, the Package Manager Console is still better than the "Manage NuGet Packages for Solution" dialog because you can paste a list of project names instead of selecting them one by one in the dialog.

Use a command such as this:

Get-Project MyProject1,MyProject2,MyProject3 | Install-Package MyPackage

Source: this answer.

If you are tempted to try to use this command from outside Visual Studio, read these questions:

Community
  • 1
  • 1
Yodan Tauber
  • 3,717
  • 2
  • 24
  • 48