Dockerfile 配置私有Nuget源
1 新建nuget.config文件,内如如下
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="NuGet" value="https://api.nuget.org/v3/index.json" />
<!--这里添加私有的Nuget地址-->
<add key="BE" value="http://192.168.0.200:8010/nuget" />
</packageSources>
</configuration>
2 Dockerfile文件中复制nuget.config
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
WORKDIR /src
COPY ["Demo/nuget.config", "Demo/"]
...
3 dotnet restore命令指定configfile
RUN dotnet restore "Demo/Demo.csproj" --configfile "Demo/nuget.config"