PowerShell尝试使用代理,即使我没有选择


0

当试图运行试图从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尝试使用代理?

Answers:


0

Powershell不使用Internet选项中指定的设置(可通过Internet Explorer访问)。必须通过netsh配置代理。
要检查当前设置的代理使用:
netsh winhttp show proxy
要清除代理设置,请使用:
netsh winhttp reset proxy
您还可以通过键入以下内容导入IE的设置:
netsh winhttp import proxy source=ie
设置或重置代理服务器需要本地计算机上的管理员权限。


有趣的是,调用netsh winhttp show proxy会给出结果“直接访问(无代理服务器)”。然而,当我运行脚本时,它仍然告诉我它正在尝试通过代理?
Cornel Verster

你能检查%appdata%\ NuGet中的文件NuGet.Config,尤其是像“http_proxy”这样的东西吗?否则可能会询问贵公司是否像NuGet的任何代理设置一样推送?
User025

在AppData / Roaming下的NuGet配置中没有代理设置。真的很奇怪!仍然得到“远程名称无法解决:'[代理]'”
Cornel Verster
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.