次の方法で共有


Windows PowerShell 5.1 の NuGet コンポーネントをブートストラップする

Windows の新しい展開では、Windows PowerShell 5.1 には、PowerShell ギャラリーと対話するために必要な NuGet コンポーネントは含まれません。 PowerShellGet には、PowerShell ギャラリーに接続できる限り、これらのコンポーネントを更新するロジックが含まれています。 コンピューターがインターネットに接続されていない場合は、信頼できるソースから切断されたコンピューターに必要なファイルをコピーする必要があります。

必要な NuGet コンポーネントは、PowerShellGet v2 以降と PackageManagement v1.1 以降に含まれています。 これらのモジュールの新しいバージョンは、PowerShell ギャラリーから入手でき、PowerShell 6 以降に含まれています。 これらの手順は、Windows PowerShell 5.1 用です。

大事な

NuGet コンポーネントをブートストラップした後、サポートされる PowerShellGet モジュールと PackageManagement モジュールの最新バージョンをインストールする必要があります。

インターネットに接続されたコンピューターでのブートストラップ

次のプロセスでは、コンピューターがインターネットに接続されており、パブリックな場所からファイルをダウンロードできることを前提としています。

エラー: 続行するには NuGet プロバイダーが必要です

このエラーは、NuGet プロバイダーがコンピューターで使用できない場合に発生します。

Find-Module -Repository PSGallery -Verbose -Name Contoso

NuGet プロバイダーをインストールする Y でプロンプトに応答します。

NuGet provider is required to continue
PowerShellGet requires NuGet provider version '2.8.5.201' or newer to interact with NuGet
-based repositories. The NuGet provider must be available in 'C:\Program Files\PackageMan
agement\ProviderAssemblies' or 'C:\Users\user1\AppData\Local\PackageManagement\ProviderAs
semblies'. You can also install the NuGet provider by running 'Install-PackageProvider -N
ame NuGet -MinimumVersion 2.8.5.201 -Force'. Do you want PowerShellGet to install and imp
ort the NuGet provider now?
[Y] Yes  [N] No  [S] Suspend  [?] Help (default is "Y"): Y
VERBOSE: Installing NuGet provider.

Version    Name                                Type       Repository           Description
-------    ----                                ----       ----------           -----------
2.5        Contoso                             Module     PSGallery        Contoso module

エラー: 続行するには NuGet.exe が必要です

このエラーは、NuGet プロバイダーを使用できるが、nuget.exe バイナリが利用できない場合に発生します。

Publish-Module -Name Contoso -Repository PSGallery -Verbose

nuget.exeをインストールする Y でプロンプトに応答します。

NuGet.exe is required to continue
PowerShellGet requires NuGet.exe to publish an item to the NuGet-based repositories. NuGe
t.exe must be available under one of the paths specified in PATH environment variable val
ue. Do you want PowerShellGet to install NuGet.exe now?
[Y] Yes  [N] No  [S] Suspend  [?] Help (default is "Y"): Y
VERBOSE: Installing NuGet.exe.
VERBOSE: Successfully published module 'Contoso' to the module publish location 'https://
www.powershellgallery.com/api/v2/'.
Please allow few minutes for 'Contoso' to show up in the search results.

エラー: 続行するには、NuGet.exe と NuGet プロバイダーが必要です

このエラーは、NuGet プロバイダーと nuget.exe の両方がインストールされていない場合に発生します。

Publish-Module -Name Contoso -Repository PSGallery -Verbose

NuGet プロバイダーと nuget.exeの両方をインストールする Y でプロンプトに応答します。

NuGet.exe and NuGet provider are required to continue
PowerShellGet requires NuGet.exe and NuGet provider version '2.8.5.201' or newer to inter
act with the NuGet-based repositories. Do you want PowerShellGet to install both NuGet.ex
e and NuGet provider now?
[Y] Yes  [N] No  [S] Suspend  [?] Help (default is "Y"): Y
VERBOSE: Installing NuGet provider.
VERBOSE: Installing NuGet.exe.
VERBOSE: Successfully published module 'Contoso' to the module publish location 'https://
www.powershellgallery.com/api/v2/'.
 Please allow few minutes for 'Contoso' to show up in the search results.

インターネットに接続されていないコンピューター上のブートストラップ

次のプロセスでは、コンピューターがインターネットに接続されていないことを前提としています。 必要なコンポーネントをインストールするには、インターネットに接続されたマシンでブートストラップ プロセスに従い、オフラインの信頼済みプロセスを使用してプロバイダーを分離ノードに手動でコピーします。

  1. NuGet プロバイダー ファイルをオフライン コンピューターにコピーします。

    接続されているコンピューターからオフライン コンピューター上の同じ場所に C:\Program Files\PackageManagement\ProviderAssemblies\NuGet フォルダーをコピーします。

  2. PowerShellGet モジュールと PackageManagement モジュールをオフライン コンピューターにコピーします。

    接続されているコンピューターから次のモジュール フォルダーをオフライン コンピューター上の同じ場所にコピーします。

    • C:\Program Files\WindowsPowerShell\Modules\PowerShellGet
    • C:\Program Files\WindowsPowerShell\Modules\PackageManagement