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
It's the "dotnet list package" command.
In its role as a public host, NuGet itself maintains the central repository of over 100,000 unique packages at nuget.org.
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).
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
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With