尝试导入Nuget PackageProvider时出错

时间:2016-04-14 02:12:04

标签: powershell nuget

我在代理后面有一台计算机并试图安装Nuget包提供程序。我在另一个网络上的另一台PC上运行了Install-PackageProvider -Name Nuget,并将Nuget文件夹复制到$ env:ProgramFiles \ PackageManagement \ ProviderAssemblies。

如果我运行Get-PackageProvider -ListAvailable,它会显示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...

但是当我尝试运行Import-PackageProvider -Name Nuget时,我收到以下错误:

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

有什么建议吗?谢谢!

1 个答案:

答案 0 :(得分:1)

我可以使用以下方法解决代理问题:

$wc = New-Object System.Net.WebClient
$wc.Proxy.Credentials = [System.Net.CredentialCache]::DefaultNetworkCredentials
$wc.Proxy.Address = "http://proxyurl"

一旦我这样做,我就可以使用Install-PackageProvider Nuget来安装proivder。