Author Posts

April 13, 2016 at 6:32 pm

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!

April 13, 2016 at 8:25 pm

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.

April 13, 2016 at 10:05 pm

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

April 14, 2016 at 4:21 am

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

April 14, 2016 at 4:54 am

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...

April 14, 2016 at 6:48 am

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!