How does this work for restoring within the context of a .NET Core application, on a Linux Build Agent (self-hosted), Azure Artifacts (NuGet) and a Docker Multistage build?
⚠Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
Much more info is required in how to consume feeds within Azure Pipelines in different scenarios.
Here's a working sample from one of our microservices.
We use docker-compose
in the build to pass in values in various override files. For ADO Build Agents, the PAT
is the $(System.AccessToken)
I think.
FROM mcr.microsoft.com/dotnet/core/sdk:2.2.300 AS sdk-base
ARG FEED_URL
ARG PAT
FROM mcr.microsoft.com/dotnet/core/aspnet:2.2.5-alpine3.9 AS runtime-base
FROM sdk-base AS build
ARG FEED_URL
ARG PAT
# Install the Credential Provider to configure the access
RUN wget -qO- https://raw.githubusercontent.com/Microsoft/artifacts-credprovider/master/helpers/installcredprovider.sh | bash
# Configure the environment variables
ENV NUGET_CREDENTIALPROVIDER_SESSIONTOKENCACHE_ENABLED true
ENV VSS_NUGET_EXTERNAL_FEED_ENDPOINTS "{\"endpointCredentials\": [{\"endpoint\":\"${FEED_URL}\", \"password\":\"${PAT}\"}]}"
WORKDIR /src
COPY ["Router.API/Router.API.csproj", "Router.API/"]
COPY ["NuGet.config", "."]
RUN dotnet restore "Router.API/Router.API.csproj" --configfile ./NuGet.config -v quiet
COPY . .
WORKDIR "/src/Router.API"
RUN dotnet build "Router.API.csproj" -c Release -o /app -v quiet
FROM build AS publish
RUN dotnet publish "Router.API.csproj" -c Release -o /app -v quiet
FROM runtime-base AS final
WORKDIR /app
EXPOSE 80
ENV ASPNETCORE_URLS=http://+:80
ENV DOTNET_RUNNING_IN_CONTAINER=true
COPY --from=publish /app .
ENTRYPOINT ["dotnet", "router-api.dll"]
This issue hasn't been updated in more than 180 days, so we've closed it. If you feel the issue is still relevant and needs fixed, please reopen it and we'll take another look. We appreciate your feedback and apologize for any inconvenience.
Most helpful comment
Here's a working sample from one of our microservices.
We use
docker-compose
in the build to pass in values in various override files. For ADO Build Agents, thePAT
is the$(System.AccessToken)
I think.