这看起来可能是一个类似的issue https://stackoverflow.com/questions/9232160/nuget-behind-a-proxy但在 CentOS 上。我已经尝试过此线程以及其他线程上的所有解决方案,但是我仍然收到以下错误
/usr/share/dotnet/sdk/3.1.201/NuGet.targets(124,5): error : Unable to load the service index for source https://api.nuget.org/v3/index.json. [/Build/_Base/Main/Main.csproj]
/usr/share/dotnet/sdk/3.1.201/NuGet.targets(124,5): error : Response status code does not indicate success: 407 (Proxy Authentication Required). [/Build/_Base/Main/Main.csproj]
我们的公司代理启用了身份验证。将 env HTTP_PROXY HTTPS_PROXY 设置为HTTPS_PROXY=http://user:[email protected] /cdn-cgi/l/email-protection:8080
Wget 适用于https://api.nuget.org/v3/index.json
显然我们的代理可以访问互联网。
使用以下条目创建了 Nuget.Config
<?xml version="1.0" encoding="utf-8"?>
<configuration>
</configuration>
nuget config -Set http_proxy="http://proxy.mycomp.com:8080" -Set https_proxy="http://proxy.mycomp.com:8080" -Set http_proxy.user="user" -Set https_proxy.user="user" -Set http_proxy.password="pass" -Set https_proxy.password="pass" -ConfigFile Nuget.Config
最终配置如下所示
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<config>
<add key="http_proxy" value="http://proxy.mycomp.com:8080" />
<add key="https_proxy" value="http://proxy.mycomp.com:8080" />
<add key="http_proxy.user" value="user" />
<add key="https_proxy.user" value="user" />
<add key="https_proxy.password" value="pass" />
<add key="http_proxy.password" value="encryptedpass" />
</config>
即使所有这些 dotnet 构建都会失败,并出现第一个提到的代理身份验证错误。
两者结果相同dotnet-sdk-2.2-2.2.402-1.x86_64 & dotnet-sdk-3.1-3.1.201-1.x86_64
根据this https://github.com/NuGet/Home/issues/7839#issuecomment-494273107我都试过了$HOME/.config/NuGet/NuGet.Config & $HOME/.nuget/NuGet/NuGet.Config
编辑:错过了一点,设置时发生所需的代理身份验证错误
export DOTNET_SYSTEM_NET_HTTP_USESOCKETSHTTPHANDLER=0
当取消设置时
unset DOTNET_SYSTEM_NET_HTTP_USESOCKETSHTTPHANDLER
结果在这
/usr/share/dotnet/sdk/2.2.402/NuGet.targets(123,5): error : Unable to load the service index for source https://api.nuget.org/v3/index.json. [/Build/_Base/Main/Main.csproj]
/usr/share/dotnet/sdk/2.2.402/NuGet.targets(123,5): error : GSSAPI operation failed with error - Unspecified GSS failure. Minor code may provide more information (SPNEGO cannot find mechanisms to negotiate). [/Build/_Base/Main/Main.csproj]
Dotnet Linux 软件包的文档似乎还不够,非常感谢任何帮助。