Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Displaying a NuGet package's dependencies

Tags:

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)?

like image 837
Unsliced Avatar asked Jan 27 '12 17:01

Unsliced


People also ask

Where can you find information about NuGet packages and their dependencies?

A Visual Studio project is defined by a . csproj file, which is an XML file that holds different configuration settings for the project. The information about the NuGet package dependencies for your project is stored in this . csproj file.

How do I view Nupkg contents?

Because NUPKG files are compressed with zip compression, you can also extract the files contained within them using zip utilities such as: Microsoft File Explorer (Windows) 7-Zip (Windows)

Does NuGet package include dependencies?

Any time a package is installed or reinstalled, which includes being installed as part of a restore process, NuGet also installs any additional packages on which that first package depends. Those immediate dependencies might then also have dependencies on their own, which can continue to an arbitrary depth.

Does NuGet automatically install dependencies?

By default, when installing NuGet packages, corresponding package dependencies will also be installed in your project. To avoid the installation of dependent packages, choose the Ignore Dependencies option in the Dependency behavior drop-down in NuGet Package Manager.


2 Answers

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] 
like image 52
x0n Avatar answered Sep 17 '22 12:09

x0n


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
like image 45
DavidG Avatar answered Sep 19 '22 12:09

DavidG