docker - 使用私有 nuget 服务器的 dotnet restore 在 docker-compose 中失败
问题描述
dotnet restore步骤仅从 docker-compose 失败,并且仅当我使用除公共服务器之外的私有 nuget 服务器时。它似乎在我的私人服务器上寻找公共包,然后超时。我收到此错误:
#15 101.5 The HTTP request to 'GET http://my-nuget/Shared/nuget/FindPackagesById()?id='Microsoft.EntityFrameworkCore.Design'&semVerLevel=2.0.0' has timed out after 100000ms.
当我手动运行 dotnet restore 时,我没有问题,而它没有在 docker 中。我在两个都使用私有和公共 nuget 服务器的项目上遇到了问题。另一个项目只使用公共服务器,并且没有问题(并且它没有 nuget.config)。
我的 nuget.config 是:
<configuration>
<packageSources>
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
<add key="USAS" value="http://my-nuget/Shared/nuget" />
</packageSources>
</configuration>
如果我删除了我的私有服务器,我会收到使用私有服务器的三个包的错误,但我不会收到公共包的错误。
解决方案
在 Dockerfile 中添加私有服务器 url dotnet restore
,如下所示:
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1-buster-slim AS base
...
RUN dotnet restore "Application.csproj" -s "YOUR PRIVATE NUGET SERVER URL"
...
推荐阅读
- c# - CKFinder NLog 不记录
- python - 如何销毁Tkinter中所有同类标签?
- scala - Spark 执行器中内存数据结构的预期行为是什么?
- java - 如何使用命令行运行 UnfoldingMaps 项目?
- java - 导致 ERROR 递归调用 appender。有没有办法解决它?
- node.js - 错误:(节点:13452)UnhandledPromiseRejectionWarning:TypeError:message.guild.roles.cache.find 不是函数
- java - 是否可以为 freemarker 模板应用自定义字体
- html - 将 SVG 标记导出为 HTML 网页中的图像
- javascript - PUT 表单数据 axios vue.js
- bluetooth - 蓝牙连接超时