我正在尝试配置一个容器来运行我的构建。 (这是Windows核心容器。)
当我在docker文件中运行nuget命令时,它失败。但是,当我将Powershell连接到容器时,它运行良好。
这是有问题的命令
nuget sources Add -Name "Common" -Source http://CompanyPackages/nuget/Common
我从docker文件中运行它,如下所示:
RUN nuget sources Add -Name "Common" -Source http://CompanyPackages/nuget/Common
并出现以下错误:
sources: invalid arguments.
但是,当我拿起容器并使用以下命令启动容器时:
docker run -it agent:v1
然后运行以下命令:
nuget sources Add -Name "Common" -Source http://CompanyPackages/nuget/Common
结果是:
Package Source with Name: Common added successfully.
我很想知道出什么问题了。但是,如果不这样做,我将对如何解决这个问题提出建议。
注意:
如果有用,这是我完整的docker文件:
FROM sixeyed/msbuild:netfx-4.5.2-webdeploy AS build-agent
SHELL ["powershell"]
RUN nuget sources Add -Name "Common" -Source http://CompanyPackages/nuget/Common
答案 0 :(得分:3)
我尝试过并使其工作如下:
如果您这样更改Dockerfile
的内容,则:
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"]
然后您再运行docker build -t yourImageName .
您最终得到这个:
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