如何在 dotnet dockerfile 中添加私有 nuget 源? [英] How to add private nuget source in dotnet dockerfile?
本文介绍了如何在 dotnet dockerfile 中添加私有 nuget 源?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我尝试将私有 nuget 源添加(覆盖)到我的构建脚本中,以便添加用户/密码 - 并将其置于我的源代码控制之外.到目前为止我尝试过的:
I try to add (override) a private nuget source to my build script in order to add the user/pw - and keep it out of my source control. What I tried so far:
nuget
未被识别为图像内的命令dotnet nuget
没有添加其他源的命令- 安装 nuget 不会影响
dotnet restore
nuget
is not recognized as command inside the imagedotnet nuget
does not have the command to add additional sources- installing nuget does not effect
dotnet restore
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 项目中:
By adding a nuget.config to the solution/project and copying it into the Docker project:
WORKDIR /src
COPY ["nuget.config", ""]
您可以添加源代码,然后您的 docker 构建就会成功.
You can add the source and then have success with your docker build.
<?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>
这篇关于如何在 dotnet dockerfile 中添加私有 nuget 源?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文