Last active
January 11, 2024 16:22
-
-
Save shubham90/ad85f2546a72caa20d57bce03ec3890f to your computer and use it in GitHub Desktop.
Dotnet restore in docker build with private Azure artifacts feed(dotnet sdk >2.1.500 )
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# downloading the dotnet sdk image. Could be any docker sdk image with sdk > 2.1.500 | |
FROM microsoft/dotnet:2.1-sdk AS dotnet-builder | |
ARG FEED_URL | |
ARG PAT | |
# download and install latest credential provider. Not required after https://github.com/dotnet/dotnet-docker/issues/878 | |
RUN wget -qO- https://raw.githubusercontent.com/Microsoft/artifacts-credprovider/master/helpers/installcredprovider.sh | bash | |
#Optional | |
WORKDIR /workdir | |
COPY ./ . | |
# Environment variable to enable seesion token cache. More on this here: https://github.com/Microsoft/artifacts-credprovider#help | |
ENV NUGET_CREDENTIALPROVIDER_SESSIONTOKENCACHE_ENABLED true | |
# Environment variable for adding endpoint credentials. More on this here: https://github.com/Microsoft/artifacts-credprovider#help | |
# Add "FEED_URL" AND "PAT" using --build-arg in docker build step. "endpointCredentials" field is an array, you can add multiple endpoint configurations. | |
# Make sure that you *do not* hard code the "PAT" here. That is a sensitive information and must not be checked in. | |
ENV VSS_NUGET_EXTERNAL_FEED_ENDPOINTS {\"endpointCredentials\": [{\"endpoint\":\"${FEED_URL}\", \"username\":\"ArtifactsDocker\", \"password\":\"${PAT}\"}]} | |
# Use this if you have a nuget.config file with all the endpoints. | |
RUN dotnet restore | |
# Optional: Extended step to build the app using dotnet msbuild. | |
RUN dotnet build dirs.proj |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment