119

How does one list all locally installed NuGet packages?

Is there a NuGet equivalent of RPM -qa? Within Chocolatey there is the chocolatey list -localonly, but for the life of me I cannot find the NuGet equivalent of that command.

Matt
  • 25,467
  • 18
  • 120
  • 187
Rhodope
  • 1,191
  • 2
  • 7
  • 3

9 Answers9

129

In the NuGet Package Manager Console, enter the following command:

Get-Package | Format-Table -AutoSize

This will either print out a list of installed packages, or if none are present write the following line to the console:

PM> Get-Package
No packages installed.

For more details, have a look at the NuGet PowerShell Reference.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Philip Allgaier
  • 3,505
  • 2
  • 26
  • 53
  • 14
    Is there a way to do this using nuget.exe? – bitbonk Dec 21 '16 at 08:25
  • 3
    After running the command `Get-Package`, [packages' names are trimmed](http://imgur.com/a/f6Vjs) when they have more than 32 characteres. Is it possible to increase the package name column so that the output show the full names without trimming them? – Ulysses Alves Mar 16 '17 at 12:44
  • 17
    `Get-Package | Format-Table -AutoSize` will do it – Mant101 May 12 '17 at 15:05
69

If you just do

Get-Package

it will list the packages and where they are referenced. It will list the same packages over and over again if you have them referenced many times. If you want to get a clean list of all packages installed in the solution you can do

Get-Package | select -Unique Id, Versions
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
bitbonk
  • 48,890
  • 37
  • 186
  • 278
18

If you have the .NET Core runtime installed, you can use the dotnet list package command in the .NET Core CLI tools to fetch installed packages for a given solution or project. Use it like so from the Windows command line:

dotnet list "C:\Source\MySolution\MySolution.sln" package

It works on both .NET Framework and .NET Core projects.

Note: For this command to work, the solution must use the new NuGet PackageReference format for referencing NuGet packages. Migration is as easy as right-clicking packages.config, and clicking "Migrate packages.config to PackageReference...", then restoring packages by building the solution.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Shahin Dohan
  • 6,149
  • 3
  • 41
  • 58
  • Does work for .NET Core but not for .NET 4.5 Solution: At least this is the case on my computer. – Christian Casutt May 30 '20 at 06:22
  • 1
    @ChristianCasutt I just tested it and it works just fine on .NET Framework 4.5, the only thing I had to do was [migrate from packages.config to PackageReference](https://learn.microsoft.com/en-us/nuget/consume-packages/migrate-packages-config-to-package-reference), and then restore nuget packages by building the solution. – Shahin Dohan Jun 01 '20 at 09:50
  • Isn't there a difference between referencing/use and installed? Aren't NuGet packages installed globally, independent of solutions/projects? – Peter Mortensen Jun 25 '20 at 09:44
  • @PeterMortensen I'm assuming here that the OP meant installed for a project/solution. Globally the downloaded packages are cached, and I don't think the term "installed" would make sense in that context. – Shahin Dohan Jun 25 '20 at 09:56
17
Get-Package -ProjectName "Your.Project.Name"

Will show the packages for the specified project.

See also: Package Manager Console PowerShell Reference

Note that each project will have a packages.config file which is used to track installed packages. If this is altered (specifically if you alter it backwards), the projects may not automatically download the correct package version. In that case, make a note of the packages required and do a uninstall-package, followed by a install-package for each.

Also, backups are your friend! ;)

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
neilhighley
  • 688
  • 7
  • 8
13

In Visual Studio,

  • go to the Project or Solution in question
  • right click, Manage NuGet Packages...
  • on the left, you will see 'Installed Packages'
  • click on this and you will see the list
Christian Phillips
  • 18,399
  • 8
  • 53
  • 82
12

In addition to all of the given answers, there is also a clean listing in XML format of all installed packages in your Visual Studio project root folder: packages.config:

Enter image description here

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
wecky
  • 754
  • 9
  • 17
  • In my opinion, the best response. – etiennejcharles Aug 16 '18 at 19:07
  • 3
    With the new project file structure introduced in Visual Studio 2017 version 15.7 NuGet packages can (or will for new projects) be moved to the project file, and you won't find a `packages.config` file. See [Microsoft documentation](https://learn.microsoft.com/en-us/nuget/consume-packages/migrate-packages-config-to-package-reference). – Frode Evensen Apr 14 '20 at 14:29
  • This only gives you one project at a time though. I have about 250 projects in my solution so other answers are better if you don't want to go through the solutions one at a time. – RosieC Oct 09 '20 at 12:19
  • For newer solutions, changes are high that you do not have a packages.config file, but instead PackageReference inside project file or even in lock files. There are now several ways to list up nuget packages ! – Tore Aurstad Nov 24 '21 at 09:09
9

Answer to "Is there a way to do this using nuget.exe? – bitbonk":

nuget list -Source C:/packages

Where C:/packages is a path to your local repository.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
jstar
  • 847
  • 9
  • 9
7

How do I list all installed NuGet Packages?

Assuming that NuGet is properly installed

Right click Project node and click Manage NuGet Packages

Right click Project node

See installed packages list

See installed packages

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Zameer Ansari
  • 28,977
  • 24
  • 140
  • 219
2

Answer to "Is there a way to do this using nuget.exe?" – bitbonk

Based on the answer from jstar above. I used \ instead of / which fits more to the Windows environment where nuget is at home. My edit of the answer was rejected so I post my own.

nuget list -Source c:\code\packages

Where c:\code is a path to your local code-repository. The packages folder is on the same level like your solution-file (*.sln).

KargWare
  • 1,746
  • 3
  • 22
  • 35