C#
C#

help

Root Question Message

DeepRobin
DeepRobin9/27/2022
NuGet behind a proxy

Hey I am in the process of releasing a .NET project as a Docker container.
How can I configure Nuget to use the proxy from the HTTP_PROXY & HTTPS_PROXY environment variables?

Currently it fails on restore as it can't resolve the feed.

Current Dockerfile:
FROM mcr.microsoft.com/dotnet/runtime:6.0-alpine AS base
WORKDIR /app

FROM mcr.microsoft.com/dotnet/sdk:6.0-alpine AS build
ARG HTTP_PROXY
ARG HTTPS_PROXY
ARG AZURE_DEVOPS_ACCESS_TOKEN
ENV HTTP_PROXY ${HTTP_PROXY}
ENV HTTPS_PROXY ${HTTPS_PROXY}
ENV AZURE_DEVOPS_ACCESS_TOKEN ${AZURE_DEVOPS_ACCESS_TOKEN}
WORKDIR /src
RUN dotnet nuget add source --name "my_feed" --username unused --store-password-in-clear-text --password ${AZURE_DEVOPS_ACCESS_TOKEN} "http://my_feed.tld/nuget/v3/index.json"
COPY ["tools/InboxCleanup/InboxCleanup.csproj", "tools/InboxCleanup/"]
COPY ["tools/lib/KMS.Tools.Common/KMS.Tools.Lib.Common.csproj", "tools/lib/KMS.Tools.Common/"]
RUN dotnet restore "tools/InboxCleanup/InboxCleanup.csproj"
COPY . .
WORKDIR "/src/tools/InboxCleanup"
RUN dotnet build "InboxCleanup.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "InboxCleanup.csproj" -c Release -o /app/publish

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "InboxCleanup.dll"]
DeepRobin
DeepRobin9/27/2022
It is dotnet nuget and not the NuGet.exe, which is downloadable at nuget.org.
Second is iirc only available on windows
SUPER MEGA T REX
SUPER MEGA T REX9/27/2022
Ah, fair, it does appear you can generate a configuration (dotnet new nugetconfig) that you could then provide the values in.
SUPER MEGA T REX
SUPER MEGA T REX9/27/2022
Although it would appear that you should be able to get away with just the environment variable set correctly (as per https://github.com/NuGet/Home/issues/6978)
DeepRobin
DeepRobin9/27/2022
as you see the env does not work 😄
ContactFrequently Asked QuestionsJoin The DiscordBugs & Feature RequestsTerms & Privacy