分享方式:


Get-Package (Visual Studio 中的 封裝管理員 控制台)

本主題描述 Windows 上 Visual Studio 封裝管理員 主控台內的命令。 如需一般 PowerShell Get-Package 命令,請參閱 PowerShell PackageManagement 參考

擷取安裝在本機存放庫中的套件清單、列出與 -ListAvailable 參數搭配使用時可從套件來源取得的套件,或列出搭配 -Update 參數使用的可用更新。

語法

Get-Package -Source <string> [-ListAvailable] [-Updates] [-ProjectName <string>]
    [-Filter <string>] [-First <int>] [-Skip <int>] [-AllVersions] [-IncludePrerelease]
    [-PageSize] [<CommonParameters>]

沒有參數, Get-Package 會顯示預設專案中安裝的套件清單。

參數

參數 描述
來源 封裝 的 URL 或資料夾路徑。 本機資料夾路徑可以是絕對路徑,或相對於目前資料夾。 如果省略, Get-Package 請搜尋目前選取的套件來源。 與 -ListAvailable 搭配使用時,預設為 nuget.org。
ListAvailable 列出套件來源提供的套件,預設為 nuget.org。除非指定 -PageSize 和/或 -First,否則會顯示預設為 50 個套件。
更新 列出可從套件來源取得更新的套件。
ProjectName 要從中取得已安裝套件的專案。 如果省略,則會傳回整個解決方案的已安裝專案。
篩選器 篩選字串,用來將它套用至套件標識碼、描述和標籤,以縮小套件清單的範圍。
First 要從清單開頭傳回的套件數目。 如果未指定,則預設為 50。
跳過 省略顯示清單中的第一個 <int> 套件。
AllVersions 顯示每個套件的所有可用版本,而不是只顯示最新版本。
IncludePrerelease 在結果中包含發行前版本套件。
PageSize (3.0+) 與 -ListAvailable 搭配使用時(必要),提供繼續提示之前要列出的套件數目。

這些參數都不接受管線輸入或通配符。

一般參數

Get-Package 支援下列 常見的 PowerShell 參數:D ebug、Error Action、ErrorVariable、OutBuffer、OutVariable、PipelineVariable、Verbose、WarningAction 和 WarningVariable。

範例

# Lists the packages installed in the current solution
Get-Package

# Lists the packages installed in a project
Get-Package -ProjectName MyProject

# Lists packages available in the current package source
Get-Package -ListAvailable

# Lists 30 packages at a time from the current source, and prompts to continue if more are available
Get-Package -ListAvailable -PageSize 30

# Lists packages with the Ninject keyword in the current source, up to 50
Get-Package -ListAvailable -Filter Ninject

# List all versions of packages matching the filter "jquery"
Get-Package -ListAvailable -Filter jquery -AllVersions

# Lists packages installed in the solution that have available updates
Get-Package -Updates

# Lists packages installed in a specific project that have available updates
Get-Package -Updates -ProjectName MyProject