我按照 在代理后使用 PowerShell中提到的步骤配置代理服务器。
netsh winhttp set proxy "[IP]:[Port]"
$Wcl = New-Object System.Net.WebClient
$Creds = Get-Credential
$Wcl.Proxy.Credentials = $Creds
弹出一个对话框在第三行收集我的证书。
然后我试着安装 NuGet:
PS C:\Users\Administrator> Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force
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 -MinimumVersion 2.8.5.201 -Force
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (Microsoft.Power...PackageProvider:InstallPackageProvider) [Install-PackageProvider], Exception
+ FullyQualifiedErrorId : NoMatchFoundForProvider,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackageProvider
错误消息似乎表明我的 PowerShell 无法连接到互联网,但当我尝试这个命令:
PS C:\Users\Administrator> Invoke-WebRequest "https://go.microsoft.com/fwlink/?LinkID=627338&clcid=0x409"
StatusCode : 200
StatusDescription : OK
Content : <?xml version="1.0" encoding="utf-8"?>
<SoftwareIdentity xmlns="http://standards.iso.org/iso/19770/-2/2015/schema.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:discovery="http://p...
RawContent : HTTP/1.1 200 OK
Content-MD5: 01uMBNqAHedJsS1dqKC5oA==
Vary: Accept-Encoding
X-Cache: HIT
x-ms-blob-type: BlockBlob
x-ms-lease-status: unlocked
x-ms-request-id: 1b7af5a7-901e-0003-5d94-f5cc950000...
Forms : {}
Headers : {[Content-MD5, 01uMBNqAHedJsS1dqKC5oA==], [Vary, Accept-Encoding], [X-Cache, HIT],
[x-ms-blob-type, BlockBlob]...}
Images : {}
InputFields : {}
Links : {}
ParsedHtml : System.__ComObject
RawContentLength : 1847
看起来它终于可以连接到互联网了。
我做错了什么? 我如何安装 NuGet?
编辑: 我试过 Ocaso Protal 的建议:
PS C:\Users\Administrator> Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force -proxy [ProxyServer:Port] -proxycredential $Creds
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 -MinimumVersion 2.8.5.201 -Force ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (Microsoft.Power...PackageProvider:InstallPackageProvider) [Install-Pac
kageProvider], Exception
+ FullyQualifiedErrorId : NoMatchFoundForProvider,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackagePro
vider
PS C:\Users\Administrator> $Creds
UserName Password
-------- --------
[My UserName] System.Security.SecureString
看起来没什么效果。