![尽管我未选择任何代理,但 PowerShell 仍尝试使用代理](https://linux22.com/image/1572633/%E5%B0%BD%E7%AE%A1%E6%88%91%E6%9C%AA%E9%80%89%E6%8B%A9%E4%BB%BB%E4%BD%95%E4%BB%A3%E7%90%86%EF%BC%8C%E4%BD%86%20PowerShell%20%E4%BB%8D%E5%B0%9D%E8%AF%95%E4%BD%BF%E7%94%A8%E4%BB%A3%E7%90%86.png)
当尝试运行尝试从 NuGet 网站下载某些内容的脚本时,我收到以下错误:
Preparing to run build script...
Unable to find version '0.30.0' of package 'Cake'.
C:\Users\user\.nuget\packages\: Package 'Cake.0.30.0' is not found on source 'C:\Users\user\.nuget\packages\'.
C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\: Package 'Cake.0.30.0' is not found on source 'C:\Program Files (
x86)\Microsoft SDKs\NuGetPackages\'.
https://api.nuget.org/v3/index.json: Unable to load the service index for source https://api.nuget.org/v3/index.json.
An error occurred while sending the request.
The remote name could not be resolved: '[proxyname]'
An error occurred while restoring NuGet tools.
At C:\Users\user\Documents\location\build.ps1:168 char:9
+ Throw "An error occurred while restoring NuGet tools."
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: (An error occurr...ng NuGet tools.:String) [], RuntimeException
+ FullyQualifiedErrorId : An error occurred while restoring NuGet tools.
请注意,我已将代理名称替换为 [proxyname]。此错误很奇怪,因为我已将 Internet 选项设置为自动检测,并且不使用代理。代理仅适用于我的工作。有没有办法阻止 PowerShell 尝试使用代理?
答案1
Powershell 不使用 Internet 选项中指定的设置(可通过 Internet Explorer 访问)。必须通过 netsh 配置代理。
要检查当前设置的代理,请使用:
netsh winhttp show proxy
要清除代理设置,请使用:
netsh winhttp reset proxy
您还可以通过键入以下内容导入 IE 的设置:
netsh winhttp import proxy source=ie
设置或重置代理服务器需要在本地计算机上拥有管理员权限。