[build-env 5/7] RUN dotnet restore:
#12 1.506 Determining projects to restore...
#12 48.75 /usr/share/dotnet/sdk/5.0.401/NuGet.targets(131,5): error : Unable to load the service index for source https://api.nuget.org/v3/index.json. [/app/OptimizerContainerAPI.csproj]
#12 48.75 /usr/share/dotnet/sdk/5.0.401/NuGet.targets(131,5): error : The SSL connection could not be established, see inner exception. [/app/OptimizerContainerAPI.csproj]
#12 48.75 /usr/share/dotnet/sdk/5.0.401/NuGet.targets(131,5): error : The remote certificate is invalid because of errors in the certificate chain: PartialChain [/app/OptimizerContainerAPI.csproj]
下面是我的 Dockerfile 的片段
#Get base image for the .Net Core from Microsoft
FROM mcr.microsoft.com/dotnet/sdk:5.0 as build-env
WORKDIR /app
#copy the CSPROJ files and restore any dependicies
COPY *.csproj ./
COPY NuGet.Config ./
RUN dotnet restore
#Copy the project files and build our release
COPY . ./
RUN dotnet publish -c Release -o out
#Generate Runtime image
FROM mcr.microsoft.com/dotnet/aspnet:5.0
WORKDIR /app
EXPOSE 80
COPY --from=build-env /app/out .
ENTRYPOINT [ "dotnet", "OPTIMIZERCONTAINERAPI.dll"]
我的私有 NuGet 源之一遇到了类似的问题,但在 Dockerfile 中手动添加 NuGet 源和凭据(而不是提供 Nuget.Config 文件)后,它对我有用。
#Restore dependencies
RUN dotnet nuget add source https://nuget.pkg.github.com/XXXX/index.json -n github --username XXXX --password XXXX --store-password-in-clear-text
RUN dotnet restore