Dotnet restore 在本地运行良好,但在构建服务器上挂起。来自私有 NuGet 存储库的包超时

Dotnet restore works fine locally, but hangs on build server. Times out on packages from private NuGet repository

我们通过 TFS 构建代理工具在构建服务器上执行 dotnet restore 命令。直到今天,我们所有从 NuGet 源恢复的包都很好。今天我们添加了一些 NuGet 包,这些包指向私有 Proget、NuGet 存储库中的包。它开始在 TFS 日志中抛出错误:

Retrying 'FindPackagesByIdAsyncCore' for source 'http://proget/[our-domain]/nuget/NUGET/FindPackagesById()?id='packagename''.

然后就超时了。我检查了我的 NuGet.Config 文件以确保代理设置有效。这对于代理外的包没有任何问题。这是设置:

<configuration>
    <config>
        <add key="http_proxy" value="http://ourproxy:port" />
    </config>

为什么这不起作用?

我终于弄明白是怎么回事了,其实是Docker帮我找到了问题所在。 Docker 要求在代理后面使用私有注册表时,排除私有注册表的域。同样,NuGet 也需要为私人提要进行该设置。

现在是配置设置:

<configuration>
    <config>
        <add key="http_proxy" value="http://ourproxy:port" />
        <add key="no_proxy" value="domainOfPrivateNuGetFeed" />
    </config>

添加 "no_proxy" 设置后,一切正常!