gpt4 book ai didi

.net - 如何在 dotnet dockerfile 中添加私有(private) nuget 源?

转载 作者:行者123 更新时间:2023-12-03 00:29:36 25 4
gpt4 key购买 nike

我尝试将私有(private) nuget 源添加到我的构建脚本中,以便添加用户/密码 - 并将其置于我的源代码控制之外。到目前为止我尝试过的:

  • nuget 未被识别为图像内的命令
  • dotnet nuget 没有添加其他源的命令
  • 安装 nuget 不会影响 dotnet 恢复
FROM mcr.microsoft.com/dotnet/core/sdk:2.2 
RUN apt-get update && apt-get install -y nuget
RUN nuget source Add -Name "Private Feed" -Source ".." -UserName "UserVAR" -Password "PassVAR"
RUN dotnet restore

最佳答案

通过将 nuget.config 添加到解决方案/项目并将其复制到 Docker 项目中:

WORKDIR /src
COPY ["nuget.config", ""]

您可以添加源代码,然后成功构建 docker。

<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
<add key="Nellson Nuget Repo" value="http://private.source.local:123/v3/index.json" />
</packageSources>
<activePackageSource>
<add key="NuGet official package source" value="https://api.nuget.org/v3/index.json" />
<add key="Nellson Nuget Repo" value="http://private.source.local:123/v3/index.json" />
</activePackageSource>
</configuration>

关于.net - 如何在 dotnet dockerfile 中添加私有(private) nuget 源?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57462205/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com