21

When you show the Manage NuGet Packages dialog box, it will show the available packages with a lot more information than is apparently available than from the powershell.

In particular, is there a way from the powershell which will list the available packages - or just a single specific package - with the packages they are dependent on, ideally with their target version (ranges)?

Unsliced
  • 10,404
  • 8
  • 51
  • 81

4 Answers4

23

Yes, there is.

# shows all available packages
PM> get-package -list

 # get single package info
PM> get-package -list solrnet.nhibernate

# view dependencies
PM> get-package -list solrnet.nhibernate | select dependencies
NHibernate:[2.1.2.4000]|CommonServiceLocator:[1.0]|SolrNet:[0.3.1] 
x0n
  • 51,312
  • 7
  • 89
  • 111
  • 2
    There doesn't seem to be dependencies in the list in VS2015 – lc. Feb 16 '16 at 16:02
  • This doesn't appear to be PowerShell, this looks like Package Manager in Visual Studio – Michael Eakins Oct 20 '16 at 15:32
  • 17
    @MichaelEakins The NuGet package manager window in Visual Studio is implemented as a PowerShell host, ergo it *is* PowerShell. I know this, because I wrote most of it. – x0n Oct 24 '16 at 13:46
  • @x0n So you are saying the script will work in PowerShell and VS? I am asking as the original tag was for Powershell and not VS. – Michael Eakins Nov 10 '16 at 17:05
  • Get-Package does work in PowerShell -- from the PackageManagement module which is ironically not the NuGet module which provides a command with the same name in the PackageManager console ... – Jaykul Nov 16 '18 at 17:26
  • @MichaelEakins I'm sure it works, but how you would inspect a local nupkg file, which is just created myself with `dotnet pack`? And also right now I'm on macos – python_kaa Oct 30 '20 at 10:43
6

For anyone running Nuget v3 or higher (i.e. VS2015), if you run the command Get-Package, you will be given this message:

This Command/Parameter combination has been deprecated and will be removed in the next release. Please consider using the new command that replaces it: 'Find-Package [-Id]'.

The documentation for Find-Package explains the new command rather well, and you can see there is no longer a -list parameter. Unfortunately it seems neither this new nor the old one will give you the dependencies. You can see all the properties returned like this:

Find-Package | Get-Member

Which will return:

   TypeName: NuGet.PackageManagement.PowerShellCmdlets.PowerShellRemotePackage

Name              MemberType Definition
----              ---------- ----------
Equals            Method     bool Equals(System.Object obj)
GetHashCode       Method     int GetHashCode()
GetType           Method     type GetType()
ToString          Method     string ToString()
AllVersions       Property   bool AllVersions {get;set;}
AsyncLazyVersions Property   Microsoft.VisualStudio.... snip
Description       Property   string Description {get;set;}
Id                Property   string Id {get;set;}
LicenseUrl        Property   string LicenseUrl {get;set;}
Version           Property   NuGet.SemanticVer.... snip
Versions          Property   System.Collections.... snip
DavidG
  • 113,891
  • 12
  • 217
  • 223
  • 5
    This is correct, but .. how do you find the dependencies now then ? – Noctis Dec 05 '16 at 03:14
  • 1
    @Noctis Like I said in my answer, you can't do it with Powershell now. There's nothing stopping you forking the [cmdlets on GitHub](https://github.com/NuGet/NuGet.Client/tree/dev/src/NuGet.Clients/PackageManagement.PowerShellCmdlets/Cmdlets) though, or even better, submitting a pull request – DavidG Dec 05 '16 at 11:34
  • 1
    For [PowerShell PackageManagement](https://learn.microsoft.com/en-us/powershell/module/packagemanagement/) `Find-Package | Get-Member` returns a type of `Microsoft.PackageManagement.Packaging.SoftwareIdentity` in v5.1. This includes the `Dependencies` member of type `IEnumerable`. – wolfyuk Apr 19 '18 at 08:26
  • @wolfyuk maybe you remember and can help, but I cannot get this to work (using VS2019 16.5, doing "$PSVersionTable" in package manager console returns among others: "PSVersion 5.1.18362.628 BuildVersion 10.0.18362.628". Any suggestions? – ciuly May 13 '20 at 18:50
  • @ciuly Sorry, not sure I can help with this now – wolfyuk May 14 '20 at 12:46
1

I used:

Find-Package <PackageName> -IncludeDependencies

https://learn.microsoft.com/en-us/powershell/module/packagemanagement/find-package?view=powershell-7.1

avenmia
  • 2,015
  • 4
  • 25
  • 49
-5
  1. Go to https://www.nuget.org/
  2. Search for the package you want
  3. Scroll down to the section Dependencies
Erick B
  • 478
  • 5
  • 11