NuGet on the Docker

Viewed 7046

Is there a way get NuGet on a linux based Docker image?

I tried this:

ARG PAT

FROM microsoft/dotnet:sdk AS build
WORKDIR /app

COPY src/IdentityServer/ ./

# the annoying NuGet installation
RUN wget -q https://packages.microsoft.com/config/ubuntu/16.04/packages-microsoft-prod.deb
RUN dpkg -i packages-microsoft-prod.deb
RUN apt-get install nuget
RUN nuget sources add -name yyyy-source https://xxxx.pkgs.visualstudio.com/_packaging/yyyy/nuget/v3/index.json -username dummy -password ${PAT}
RUN dotnet publish -c Release -o out

FROM microsoft/dotnet:aspnetcore-runtime AS runtime
WORKDIR /app
COPY --from=build /app/out ./
ENTRYPOINT ["dotnet", "IdentityServer.dll"]

I get this:

Step 5/13 : RUN wget -q https://packages.microsoft.com/config/ubuntu/16.04/packages-microsoft-prod.deb
 ---> Using cache
 ---> db337597f4fe
Step 6/13 : RUN dpkg -i packages-microsoft-prod.deb
 ---> Running in c361881586a3
Selecting previously unselected package packages-microsoft-prod.
(Reading database ... 12109 files and directories currently installed.)
Preparing to unpack packages-microsoft-prod.deb ...
Unpacking packages-microsoft-prod (1.0-3) ...
Setting up packages-microsoft-prod (1.0-3) ...
Removing intermediate container c361881586a3
 ---> 6a56d436e5da
Step 7/13 : RUN apt-get install nuget
 ---> Running in c47705590796
Reading package lists...
Building dependency tree...
Reading state information...
E: Unable to locate package nuget
The command '/bin/sh -c apt-get install nuget' returned a non-zero code: 100

but some people have success getting that NuGet package installed on Linux: How to install NuGet from command line on linux

1 Answers

I see the only reason you're trying to get nuget.exe is to add credentials. This page in the docs has links on how to authenticate to Azure Devops using the dotnet cli. Your use case falls into the "otherwise" sentence of the CI builds section, so you can use an environment variable to specify your PAT. Therefore, you don't actually need nuget.

Related