TLDR 版本:我需要能够附加到巧克力包为其下载源指定的 URL 的末尾。
我正在尝试使用 Chocolatey 安装 Android-SDK 包,但我的过滤代理出现问题(我无法控制它的功能和提供)。代理被正确检测到,但它会阻止包含某些模式的 URL 并发出 403 返回(在这种情况下,这是因为 URL 指向 a .exe
)。所以运行choco install -y android-sdk
会导致以下错误。
2015-03-12 15:14:47,639 [INFO ] - ============================================================
2015-03-12 15:14:47,664 [INFO ] - Chocolatey v0.9.9.2
2015-03-12 15:14:47,730 [INFO ] - Installing the following packages:
2015-03-12 15:14:47,753 [INFO ] - android-sdk
2015-03-12 15:14:47,754 [INFO ] - By installing you accept licenses for the packages.
2015-03-12 15:14:49,221 [INFO ] -
android-sdk v24.0.2
2015-03-12 15:14:50,525 [INFO ] - Using this proxyserver: xxx.xxx.xxx.xxx:xxxxx
2015-03-12 15:14:52,175 [INFO ] - Attempt to get headers for http://dl.google.com/android/installer_r24.0.2-windows.exe failed.
2015-03-12 15:14:52,175 [INFO ] - Exception calling "GetResponse" with "0" argument(s): "The remote server returned an error: (403) Forbidden."
2015-03-12 15:14:52,180 [INFO ] - Downloading android-sdk 32 bit
2015-03-12 15:14:52,180 [INFO ] - from 'http://dl.google.com/android/installer_r24.0.2-windows.exe'
2015-03-12 15:14:52,213 [INFO ] - Using this proxyserver: xxx.xxx.xxx.xxx:xxxxx
2015-03-12 15:14:52,329 [ERROR] - Exception calling "GetResponse" with "0" argument(s): "The remote server returned an error: (403) Forbidden."
2015-03-12 15:14:52,330 [ERROR] - At C:\ProgramData\chocolatey\helpers\functions\Get-WebFile.ps1:66 char:3
2015-03-12 15:14:52,330 [ERROR] - + $res = $req.GetResponse();
2015-03-12 15:14:52,330 [ERROR] - + ~~~~~~~~~~~~~~~~~~~~~~~~~
2015-03-12 15:14:52,331 [ERROR] - + CategoryInfo : NotSpecified: (:) [], MethodInvocationException
2015-03-12 15:14:52,331 [ERROR] - + FullyQualifiedErrorId : WebException
2015-03-12 15:14:52,354 [ERROR] - You cannot call a method on a null-valued expression.
2015-03-12 15:14:52,354 [ERROR] - At C:\ProgramData\chocolatey\helpers\functions\Get-WebFile.ps1:138 char:3
2015-03-12 15:14:52,355 [ERROR] - + $res.Close();
2015-03-12 15:14:52,356 [ERROR] - + ~~~~~~~~~~~~
2015-03-12 15:14:52,356 [ERROR] - + CategoryInfo : InvalidOperation: (:) [], RuntimeException
2015-03-12 15:14:52,357 [ERROR] - + FullyQualifiedErrorId : InvokeMethodOnNull
2015-03-12 15:14:54,374 [ERROR] - Chocolatey expected a file to be downloaded to
2015-03-12 15:14:54,375 [ERROR] - 'X:\Users\xxx\AppData\Local\Temp\chocolatey\android-sdk\android-sdkInstall.exe' but nothing exists at that
2015-03-12 15:14:54,375 [ERROR] - location.
2015-03-12 15:14:54,376 [ERROR] - At C:\ProgramData\chocolatey\helpers\functions\Get-ChocolateyWebFile.ps1:148 char:24
2015-03-12 15:14:54,376 [ERROR] - + if (!($fi.Exists)) {{ throw "Chocolatey expected a file to be downloaded to `'$ ...
2015-03-12 15:14:54,377 [ERROR] - + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2015-03-12 15:14:54,377 [ERROR] - + CategoryInfo : OperationStopped: (Chocolatey expe... that location.:String) [], RuntimeException
2015-03-12 15:14:54,378 [ERROR] - + FullyQualifiedErrorId : Chocolatey expected a file to be downloaded to 'X:\Users\xxx\AppData\Local\Temp\cho
2015-03-12 15:14:54,378 [ERROR] - colatey\android-sdk\android-sdkInstall.exe' but nothing exists at that location.
2015-03-12 15:14:54,618 [ERROR] - android-sdk install not successful.
2015-03-12 15:14:54,621 [ERROR] - Error while running 'C:\ProgramData\chocolatey\lib\android-sdk\tools\chocolateyInstall.ps1'.
See log for details.
2015-03-12 15:14:56,643 [WARN ] -
Chocolatey installed 0/1 package(s). 1 package(s) failed.
See the log for details.
2015-03-12 15:14:56,643 [ERROR] - Failures:
2015-03-12 15:14:56,645 [ERROR] - - android-sdk
我可以创建自己的包,chocolateyInstall.ps1
并chocolateyUninstall.ps1
在包的网页上列出并更改 URL,但这否定了使用包管理器来简化管理程序和依赖项的过程的任何好处。
所以我想知道是否有某种方法可以简单地附加一个字符串,该字符串允许 URL 通过代理而不管文件扩展名(要清楚,我知道这个字符串是什么,我只是不知道如何附加它到包指定的 URL)。