85

I'd like to get the NuGet.exe version using the command-line.

I know I can get the version of NuGet running as part of Visual Studio, as per the instructions here, but what I'm after is something similar from the command-line, i.e like:

nuget --version

Any ideas?

Legends
  • 21,202
  • 16
  • 97
  • 123
Per Samuelsson
  • 1,000
  • 1
  • 6
  • 8

6 Answers6

103

Typing nuget help from the command line will in addition to the expected help information also list the current NuGet.exe version.

Julian
  • 20,008
  • 17
  • 77
  • 108
  • 7
    try `nuget help | head -1` for a single line result. – tkerwood Jul 05 '17 at 23:15
  • 17
    Or `nuget help | select -First 1` if you're on Windows (PowerShell). – Julian Jul 06 '17 at 08:38
  • Any idea why that powershell command gives an exit code of 1? – ThetaSinner Oct 16 '18 at 09:31
  • @ThetaSinner: The PowerShell command `nuget help | select -First 1` works just fine and returns the current NuGet version. If you're having problems a bit more context is needed to help you (and it probably belongs in a separate question as well). – Julian Oct 18 '18 at 07:04
  • A comment accompanying the down-vote would be highly appreciated, perhaps event with an edit suggestion to improve the answer... – Julian Jun 14 '19 at 12:39
59

To know which version of NuGet is installed use follow steps

  • In Visual Studio, use the Help > About Microsoft Visual Studio command and look at the version displayed next to NuGet Package Manager.

  • Alternatively, launch the Package Manager Console (Tools > NuGet Package Manager > Package Manager Console) and enter $host to see information about NuGet including the version.

Athari
  • 33,702
  • 16
  • 105
  • 146
Niraj Trivedi
  • 2,370
  • 22
  • 24
  • 2
    displaying different versions in About: NuGet Package Manager 4.6.0 and Console: Package Manager Host 4.7.0.5212 – volody Oct 17 '18 at 21:36
  • 2
    The same with me @volody, the first option in my case gives "**4.6.0**" also, and the second option "**4.9.2.5706**". It would seem that the version details are not in sync? [This page from Microsoft](https://learn.microsoft.com/en-us/nuget/policies/nuget-faq#nuget-in-visual-studio) also suggests the same as this answer. – Anthony Walsh Jan 21 '19 at 17:23
12

Windows Powershell:

nuget help | select -First 1

enter image description here


Cmd.exe
nuget ?

enter image description here


Not working anymore

Command line (cmd.exe) | Package Manager Console in Visual Studio

1.) nuget ? v
2.) nuget help v

enter image description here

The "v" command is actually not valid, but with this approach you only get the nuget version number and below the information that "v" is an unknow command.

Legends
  • 21,202
  • 16
  • 97
  • 123
  • 3
    interestingly enough, v actually triggers nuget verify now in newer versions, (tested with 4.9.3.5777) and is no longer an unknown command – Jonathan Niu Mar 14 '19 at 02:50
4

In the .NET 6 era, I use this command to see version of Nuget:

dotnet nuget --version

It will reply something like this:

NuGet Command Line
6.2.0.146

Works identically on both Windows and Linux.

Afshar Mohebi
  • 10,479
  • 17
  • 82
  • 126
0

I had his very question, in my Centos7 Docker container.

This is how I solved it:

yum info nuget

yum info nuget returns a great deal! Just wanting the numbers, I added a grep and a sed to clean things up.

yum info nuget | grep Version | sed 's/^.*: //'

To put in in a variable in your bash script:

nuget_version=$(yum info nuget | grep Version | sed 's/^.*: //')
Jesse Chisholm
  • 3,857
  • 1
  • 35
  • 29
0

On Windows 10 CMD console, try this:

C:>nuget help |findstr "NuGet Version"

On Windows 10 PowerShell console, try this:

PS C:> nuget help | select -First 1

Both of them will return something like:

NuGet Version: 5.8.1.7021

TianCaiBenBen
  • 691
  • 5
  • 2