Error trying to import Nuget PackageProvider

I have a computer behind a proxy and trying to get the Nuget package provider installed. I ran Install-PackageProvider -Name Nuget on a different PC on a different network and copied Nuget folder to $env:ProgramFiles\PackageManagement\ProviderAssemblies.

If I run Get-PackageProvider -ListAvailable it shows Nuget available.

PS C:\Windows\system32> Get-PackageProvider -ListAvailable

Name Version DynamicOptions


msi 3.0.0.0 AdditionalArguments
msu 3.0.0.0
nuget 2.8.5.204
PowerShellGet 1.0.0.1 PackageManagementProvider, Type, S…
Programs 3.0.0.0 IncludeWindowsInstaller, IncludeSy…

However when I try to run Import-PackageProvider -Name Nuget I get the following error:

PS C:\Windows\system32> Import-PackageProvider -Name Nuget
Import-PackageProvider : No match was found for the specified search criteria and provider name ‘Nuget’. Try ‘Get-PackageProvider -ListAvailable’ to see if the provider exists on the system.At line:1 char:1

  • Import-PackageProvider -Name Nuget
  • CategoryInfo : InvalidData: (Nuget:String) [Import-PackageProvider], Exception
  • FullyQualifiedErrorId : NoMatchFoundForCriteria,Microsoft.PowerShell.PackageManagement.Cmdlets.ImportPackageProvider

Any suggestions? Thank you!

Add -verbose and post the results. I had something similar and the verbose was showing that I was having issues reaching newget.org Our company uses OpenDNS and the site had been classified as “dynamic” and was blocked.

To get nuget to install using Install-PackageProvider from behind our proxy I had to run the following 2 lines first

$wc = New-Object System.Net.WebClient
$wc.Proxy.Credentials = [System.Net.CredentialCache]::DefaultNetworkCredentials

I’ve added them to my profile to avoid further issues

The PackageManagement code is a bit tricky to follow in ILSpy, but you might try using a full path to the DLL when calling Import-PackageProvider, to see if there’s any difference:

$path = (Get-PackageProvider -Name Nuget -ListAvailable).ProviderPath
Import-PackageProvider $path

Thanks for all of the replies.

Dave,

I tried what you mentioned and it’s odd. I didn’t get an error importing, however Nuget doesn’t show if I run Get-PackageProvider.

PS C:\Windows\system32> $path = (Get-PackageProvider -Name Nuget -ListAvailable)
.ProviderPath
PS C:\Windows\system32> $path
C:\Program Files (x86)\PackageManagement\ProviderAssemblies\nuget\2.8.5.204\Micr
osoft.PackageManagement.NuGetProvider.dll
PS C:\Windows\system32> Import-PackageProvider $path -Verbose
VERBOSE: Loading an assembly ‘C:\Program Files
(x86)\PackageManagement\ProviderAssemblies\nuget\2.8.5.204\Microsoft.PackageMan
agement.NuGetProvider.dll’.
PS C:\Windows\system32> Get-PackageProvider

Name Version DynamicOptions


msi 3.0.0.0 AdditionalArguments
msu 3.0.0.0
PowerShellGet 1.0.0.1 PackageManagementProvider, Type, S…
Programs 3.0.0.0 IncludeWindowsInstaller, IncludeSy…

I never figured out issues with Import-PackageProvider however I was able to get Henry’s solution to work for me. I had to also add the the proxy address because we use a configuration file to redirect traffic, so that was another hour of troubleshooting.

Thanks again for everyone help!