How do I install the Nuget provider for PowerShell on a unconnected machine so I can install a nuget package from the PS command line?

前端 未结 5 1406
有刺的猬
有刺的猬 2020-12-24 11:16

I\'m trying to install pswindowsupdate.2.0.0.4.nupkg from the Powershell command line on a Win 7 computer not connected to the internet. I\'m running PS 5.1.14

5条回答
  •  执念已碎
    2020-12-24 11:38

    MSDocs state this for your scenario:

    In order to execute the first time, PackageManagement requires an internet connection to download the Nuget package provider. However, if your computer does not have an internet connection and you need to use the Nuget or PowerShellGet provider, you can download them on another computer and copy them to your target computer. Use the following steps to do this:

    1. Run Install-PackageProvider -Name NuGet -RequiredVersion 2.8.5.201 -Force to install the provider from a computer with an internet connection.

    2. After the install, you can find the provider installed in $env:ProgramFiles\PackageManagement\ReferenceAssemblies\\\\\\ or $env:LOCALAPPDATA\PackageManagement\ProviderAssemblies\\\\\\.

    3. Place the folder, which in this case is the Nuget folder, in the corresponding location on your target computer. If your target computer is a Nano server, you need to run Install-PackageProvider from Nano Server to download the correct Nuget binaries.

    4. Restart PowerShell to auto-load the package provider. Alternatively, run Get-PackageProvider -ListAvailable to list all the package providers available on the computer. Then use Import-PackageProvider -Name NuGet -RequiredVersion 2.8.5.201 to import the provider to the current Windows PowerShell session.

提交回复
热议问题