显示 NuGet 包的依赖项

发布于 2024-12-29 12:31:35 字数 152 浏览 0 评论 0原文

当您显示“管理 NuGet 包”对话框时,它将显示可用的包,其中包含的信息比 powershell 中明显提供的信息多得多。

特别是,有没有一种方法可以从 powershell 中列出可用的包 - 或者只是一个特定的包 - 以及它们所依赖的包,最好是它们的目标版本(范围)?

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

独享拥抱 2025-01-05 12:31:35

是的,有。

# 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] 

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] 
等风来 2025-01-05 12:31:35

对于运行 Nuget v3 或更高版本(即 VS2015)的任何人,如果运行命令 Get-Package,您将收到以下消息:

此命令/参数组合已被弃用,并将在下一版本中删除。请考虑使用替代它的新命令:“Find-Package [-Id]”。

Find-Package 很好地解释了新命令,您可以看到不再有 -list 参数。不幸的是,似乎新的和旧的都不会给你依赖。您可以看到返回的所有属性,如下所示:

Find-Package | Get-Member

将返回:

   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

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
往事风中埋 2025-01-05 12:31:35
  1. 转到 https://www.nuget.org/
  2. 搜索所需的包
  3. 向下滚动到该部分依赖关系
  1. Go to https://www.nuget.org/
  2. Search for the package you want
  3. Scroll down to the section Dependencies
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文