在代理后面使用 docker-compose 进行构建时,我遇到了块恢复错误。我已经在 Windows 的 docker 中设置了代理。 Nuget 恢复适用于命令行dotnet restore
和 Visual Studio 调试,但不使用docker-compose
.
:\Program Files\dotnet\sdk\2.1.104\NuGet.targets(104,5): error : Unable to load the service index for source https://api.nuget.org/v3/index.json. [C:\src\WebApp.sln]
:\Program Files\dotnet\sdk\2.1.104\NuGet.targets(104,5): error : An error occurred while sending the request. [C:\src\WebApp.sln]
:\Program Files\dotnet\sdk\2.1.104\NuGet.targets(104,5): error : A connection with the server could not be established [C:\src\WebApp.sln]
ERROR: Service 'idenityapi' failed to build: The command 'powershell -Command $ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue'; dotnet restore -nowarn:msb3202,nu1503' r
turned a non-zero code: 1
SOLVED:
事实证明这是一个网络问题。我工作时位于公司防火墙后面,该防火墙利用 TLS 数据包检查来分解 SSL 流量。调试时的构建过程在我的本地计算机上以“我”的身份运行,但是,发布构建(docker-compose)实际上会拉下一个 aspnetcore-build docker 映像,将代码复制到 docker 容器,然后运行 dotnet Restore 以获得最新信息docker 镜像的 nuget 包。这些操作可以在项目的 Docker 文件中找到。容器内的这个“dotnet Restore”在不同的安全上下文下运行,因此被挂起。我们追踪了网络流量,由于 Docker 网络的工作原理,我很难追踪到该网络流量。 Fiddler 没有捕获流量。使用wireshark,我们能够从设备级别捕获它并查看下降情况。我的家庭网络继续出现故障的原因是我们的虚拟机管理程序和网络的配置。
决议:
添加防火墙规则https://api.nuget.org/v3/index.json https://api.nuget.org/v3/index.json(首选)
或者
从云中的 VSTS 构建映像
或者
从不同的网络构建。
PS4请回帖,如果你能以同样的方式解决这个问题?花了三天时间,我很好奇你的状况。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)