List referenced Nuget Packages from the Package Manager Console

No Comments October 21, 2013

For reasons I won’t bore you with, I needed to work out what packages were installed in the solution I was working on, across all the component projects. This can be done with minimum fuss from the Package Manager Console in Visual Studio.

There are a number of useful commands available to you in the Package Manger Console, one of which is:


which on its own will give you the name of the Default project in the Package Manager Console. However:

Get-Project -All

Produces a list of all the projects in the currently loaded solution. The next interesting command is:


which gives you the list of referenced Nuget packages in the Default project. It has a switch - '-ProjectName' - which allows you to specify the project you want to get the list of packages for. Given this, and remembering that the Package Manager Console is a full Powershell instance, you can get the complete list of referenced Nuget packages with:

@(Get-Project -All | ForEach-Object { Get-Package -ProjectName $_.ProjectName }) | Select-Object -Unique | Sort-Object

or the slightly shorter form:

@(Get-Project -All | % { Get-Package -ProjectName $_.ProjectName }) | Sort -Unique

This could be useful to audit the packages used in a solution, or to help track down the situation where different projects refer to different versions of the same package.

No Comments