Installing NuGet package provider for PowerShell on offline machine: Install-PackageProvider not working but Import-PackageProvider is

I am facing issues installing the NuGet package provider for PowerShell on an offline machine.

What I’m trying to do is to copy the %programfiles%\PackageManagement\ProviderAssemblies\nuget folder from an online machine to an offline machine. Both are running the exact same PowerShell and Windows versions, so there shouldn’t be any compatibility issues. Afterwards, I would like to run Install-PackageProvider -Name NuGet and have the NuGet package provider available in any PowerShell session on the offline machine from then on. But when I do so in an elevated PowerShell after copying the files I get the following error:

WARNING: Unable to download from URI 'https://go.microsoft.com/fwlink/?LinkID=627338&clcid=0x409' to ''.
WARNING: Unable to download the list of available providers. Check your internet connection.
Install-PackageProvider : No match was found for the specified search criteria for the provider 'NuGet'. The package provider requires 'PackageManagement' and 'Provider' tags. Please check if the specified package has the tags.
At line:1 char:1
+ Install-PackageProvider -Name NuGet -Force
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (Microsoft.Power...PackageProvider:InstallPackageProvider) [Install-PackageProvider], Exception
    + FullyQualifiedErrorId : NoMatchFoundForProvider,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackageProvider

At the same time, running Import-PackageProvider -Name NuGet works perfectly well. But I’d have to run that command every time PowerShell starts, be it either manually or by including it in the profile. After running Import-PackageProvider -Name NuGet and restarting PowerShell, the package provider is not automatically loaded. That is pretty undesirable.

Adding the -Force flag to the Install-PackageProvider invocation makes no difference.

I have looked at the documentation for Install-PackageProvider but can’t seem to find any parameter I ought to be passing for offline installations like mine. Microsoft’s documentation on offline NuGet package provider installs only mentions importing the package provider and no further steps.

So I am somewhat at a loss as to what to do now. Any help would be much appreciated!

Leave a Comment