PowerShell 的套件管理

Microsoft為 PowerShell 提供三個套件管理工具:

  • Microsoft。PowerShell.PSResourceGet 模組 - 最初於 PowerShell 7.4.0 中推出
  • PowerShellGet 與 PackageManagement 模組 - 最初隨 Windows PowerShell 5.0 推出
  • Visual Studio 的 封裝管理員 主控台所使用的 NuGet 模組

本文件涵蓋了 PowerShellGet、PackageManagement 及 Microsoft。PowerShell.PSResourceGet modules. 這些模組包含 Cmdlet,可從 PowerShell 資源庫探索、安裝、更新及發佈 PowerShell 套件,。 這些套件可以包含模組、DSC 資源和腳本等成品。 Microsoft。PowerShell.PSResourceGet 模組取代了 PowerShellGet 和 PackageManagement 模組。

注意

NuGet 模組包含用於發現及安裝 NuGet Gallery 套件的 cmdlet,供 Visual Studio 專案使用。 關於 NuGet 模組的資訊,請參閱 Visual Studio 文件中的 NuGet 模組參考資料。

支援的版本:

  • 當前版本
    • Microsoft。PowerShell.PSResourceGet 1.2.0 - 一個獨立模組,不依賴 PowerShellGet 或 PackageManagement 模組
    • PowerShellGet 2.2.5 搭配 PackageManagement 1.4.8.1
  • 預覽版
    • Microsoft。PowerShell.PSResourceGet 1.3.0-preview1 - 新增許多新功能。 欲了解更多資訊,請參閱 GitHub 倉庫中的「 PSResourceGet 最新資訊 」。

為了獲得最佳效果,建議使用最新版本的 Microsoft。PowerShell.PSResourceGet module.

重要

Windows PowerShell 5.1 附帶的 1.0.0.1 版本 PowerShellGet 已不再支援。 若要支援,您必須更新為最新版本。 欲了解更多資訊,請參閱 「安裝 PowerShell 套件管理器」。

強化對 Microsoft 工件登錄檔的支援

Microsoft 新增了對 Microsoft 工件登錄檔的支援。PowerShell.PSResourceGet v1.1.0. 從 Microsoft 開始。PowerShell.PSResourceGet v1.3.0-preview1,Microsoft Artifact Registry 是與 PSGallery 倉庫並列的預設儲存庫。 請使用以下指令將 Microsoft Artifact 登錄庫註冊為預設設定:

Register-PSResourceRepository -MicrosoftArtifactRegistry

預設情況下,Microsoft Artifact Registry 儲存庫會被註冊為受信任儲存庫,優先權高於 PSGallery 儲存庫。 欲了解更多資訊,請參閱 Register-PSResourceRepository

另請參閱