Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get a list of all NuGet packages used in a solution

Tags:

c#

nuget

I'm looking for a way to get a list of all used NuGet packages in every project in a solution (and specifically the version) using command-line script and not manually in Visual Studio.

Using the Package Manager Console with the command "Get-Package" gives me what I want, but it is unavailable outside of VS.

I'm using is a local NuGet feed. My default package management format is PackageReference.

Any idea would be helpful

like image 465
Avihay Avatar asked Nov 22 '18 17:11

Avihay


People also ask

Which of the following file contains list of all the NuGet package installed for web project?

It's the "dotnet list package" command.

How many NuGet packages are there?

In its role as a public host, NuGet itself maintains the central repository of over 100,000 unique packages at nuget.org.

How do I view NuGet packages?

Find and install a packageLoad a project in Solution Explorer, and then select Project > Manage NuGet Packages. The NuGet Package Manager window opens. Select the Browse tab to display packages by popularity from the currently selected source (see Package sources).


2 Answers

PackageReference as a package management format only works on a per project basis. So you would need to "analyze" each project individually.

From the commandline, there "will" be a way to list all the packages. It's the "dotnet list package" command. I say will, because it's still in preview. You can download the 2.2.100 version from here. Related spec.

The simplest usage example is:

dotnet list YourSln.sln package

If you do not want to use a dotnet.exe preview, you can consider writing your own tool, by reading the assets files for each project, which is what the actual command does. For reference, see code here and here

like image 162
imps Avatar answered Sep 25 '22 11:09

imps


Run this command Get-Package | Select-Object Id, Version, LicenseUrl, ProjectName in package manager console in Visual Studio. taken from this answer: https://softwareengineering.stackexchange.com/a/286981

like image 44
stambikk Avatar answered Sep 24 '22 11:09

stambikk