Bootstrap dei componenti NuGet per Windows PowerShell 5.1
In una nuova distribuzione di Windows, Windows PowerShell 5.1 non include i componenti NuGet necessari per interagire con PowerShell Gallery. PowerShellGet include la logica per aggiornare questi componenti, purché sia possibile connettersi a PowerShell Gallery. Se il computer non è connesso a Internet, è necessario copiare i file necessari da un'origine attendibile al computer disconnesso.
I componenti NuGet necessari sono inclusi in PowerShellGet v2+ e PackageManagement v1.1+. Le versioni più recenti di questi moduli sono disponibili in PowerShell Gallery e incluse in PowerShell 6 e versioni successive. Queste istruzioni sono per Windows PowerShell 5.1.
Importante
Dopo il bootstrap dei componenti NuGet, è necessario installare le versioni più recenti dei moduli PowerShellGet e PackageManagement da supportare.
Bootstrap in un computer connesso a Internet
I processi seguenti presuppongono che il computer sia connesso a Internet e possa scaricare i file da un percorso pubblico.
ERRORE: Il provider NuGet è necessario per continuare
Questo errore viene visualizzato quando il provider NuGet non è disponibile nel computer.
Find-Module -Repository PSGallery -Verbose -Name Contoso
Rispondere al prompt con Y
per installare il provider NuGet.
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
ERRORE: è necessario NuGet.exe per continuare
Questo errore viene visualizzato quando il provider NuGet è disponibile, ma il file binario nuget.exe
non è.
Publish-Module -Name Contoso -Repository PSGallery -Verbose
Rispondere al prompt con Y
per installare nuget.exe
.
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.
ERRORE: NuGet.exe e il provider NuGet sono necessari per continuare
Questo errore viene visualizzato quando il provider NuGet e nuget.exe
non sono installati.
Publish-Module -Name Contoso -Repository PSGallery -Verbose
Rispondere al prompt con Y
per installare sia il provider NuGet che nuget.exe
.
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.
Bootstrap in un computer non connesso a Internet
I processi seguenti presuppongono che il computer non sia connesso a Internet. Per installare i componenti necessari, seguire il processo bootstrap in un computer connesso a Internet e quindi copiare manualmente il provider nel nodo isolato tramite un processo attendibile offline.
Copiare i file del provider NuGet nel computer offline.
Copiare la cartella
C:\Program Files\PackageManagement\ProviderAssemblies\NuGet
dal computer connesso nella stessa posizione del computer offline.Copiare i moduli PowerShellGet e PackageManagement nel computer offline.
Copiare le cartelle del modulo seguenti dal computer connesso nella stessa posizione nel computer offline.
C:\Program Files\WindowsPowerShell\Modules\PowerShellGet
C:\Program Files\WindowsPowerShell\Modules\PackageManagement