Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

171
Visualizações
Nuget command fails in docker file but not when run manually

I am trying to configure a container to run my build. (It is a windows core container.)

When I run a nuget command in the docker file, it fails. But when I connect powershell to the container, it runs fine.

This is the command in question:

nuget sources Add -Name "Common Source" -Source http://CompanyPackages/nuget/Common

I run it from the docker file like this:

RUN nuget sources Add -Name "Common Source" -Source http://CompanyPackages/nuget/Common

And get the following error:

sources: invalid arguments.

However, when I take the container and start it using:

docker run -it agent:v1

Then run the same command inside the container:

nuget sources Add -Name "Common Source" -Source http://CompanyPackages/nuget/Common

The result is:

Package Source with Name: Common added successfully.

What would cause it to fail in the dockerfile and not in the container?

Note:

In case it is useful, here is my full docker file:

 FROM sixeyed/msbuild:netfx-4.5.2-webdeploy AS build-agent
 SHELL ["powershell"]

 RUN nuget sources Add -Name "Common Source" -Source http://CompanyPackages/nuget/Common
over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

I tried it and got it working like this:

If you change the content of your Dockerfile like this:

FROM sixeyed/msbuild:netfx-4.5.2-webdeploy AS build-agent
SHELL ["powershell"]
RUN ["nuget", "sources" , "Add", "-Name", "\"Common Source\"", "-Source" ,"http://CompanyPackages/nuget/common"]

And when you then run docker build -t yourImageName .

You end up with this:

Sending build context to Docker daemon  2.048kB
Step 1/3 : FROM sixeyed/msbuild:netfx-4.5.2-webdeploy AS build-agent
 ---> 0851a5b495a3
Step 2/3 : SHELL ["powershell"]
 ---> Running in 10082a1c45f8
Removing intermediate container 10082a1c45f8
 ---> c00b912c6a8f
Step 3/3 : RUN ["nuget", "sources" , "Add", "-Name", "\"Common Source\"", "-Source" ,"http://CompanyPackages/nuget/common"]
 ---> Running in 797b6c055928
Package Source with Name: "Common Source" added successfully.
Removing intermediate container 797b6c055928
 ---> 592db3be9f8b
Successfully built 592db3be9f8b
Successfully tagged nuget-tester:latest
over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda