我正在尝试为CI管道设置Windows容器。 我的项目使用C ++和CMake,所以我使用的是Microsoft Build Tools安装程序。
注意:我无意为我的项目使用.NET框架的任何部分
不幸的是,在我的Docker容器中安装MS Build Tools失败,退出代码为5003,没有错误消息。
我无法找到此返回码的解释。我想知道是否有人可以告诉我我做错了什么?
我的Dockerfile看起来像这样:
FROM microsoft/windowsservercore:10.0.14393.1480
ADD https://aka.ms/vs/15/release/vs_buildtools.exe C:\\tmp\\vs-build-tools.exe
RUN C:\\tmp\\vs-build-tools.exe --add Microsoft.VisualStudio.Workload.VCTools --includeRecommended --quiet --passive --norestart --wait --nocache
RUN powershell -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))"
RUN %ALLUSERSPROFILE%\chocolatey\bin\choco.exe install -y git
ENTRYPOINT C:\BuildTools\Common7\Tools\VsDevCmd.bat &&
CMD ["powershell.exe", "-NoLogo", "-ExecutionPolicy", "Bypass"]
我正在使用此批处理脚本构建容器(用户名已被替换):
docker image rm someusername/cmake-msvc
docker build -t someusername/cmake-msvc -m 8g .
docker push someusername/cmake-msvc
我已经读过these Windows containers require a large amount of storage space,所以通过设置storage-opts
增加了可用空间:
"storage-opts": [
"size=120G"
]
这是我在构建时获得的控制台输出,构建崩溃需要花一些时间(我还没有计时,但我猜它大约在20到40分钟之间):
docker build -t someusername/cmake-msvc -m 8g .
Sending build context to Docker daemon 1.29MB
Step 1/7 : FROM microsoft/windowsservercore:10.0.14393.1480
---> 2c42a1b4dea8
Step 2/7 : ADD https://aka.ms/vs/15/release/vs_buildtools.exe C:\\tmp\\vs-build-tools.exe
Downloading [==================================================>] 1.286MB/1.286MB
---> 1891bae28aa1
Step 3/7 : RUN C:\\tmp\\vs-build-tools.exe --add Microsoft.VisualStudio.Workload.VCTools --includeRecommended --quiet --passive --norestart --wait --nocache
---> Running in aa6061b7134e
Preparing: C:\Users\ContainerAdministrator\AppData\Local\Temp\e86ca78527dcfbd3cf\vs_bootstrapper_d15\HelpFile\1028\help.html...
Preparing: C:\Users\ContainerAdministrator\AppData\Local\Temp\e86ca78527dcfbd3cf\vs_bootstrapper_d15\HelpFile\2052\help.html...
Preparing: C:\Users\ContainerAdministrator\AppData\Local\Temp\e86ca78527dcfbd3cf\vs_bootstrapper_d15\HelpFile\1029\help.html...
Preparing: C:\Users\ContainerAdministrator\AppData\Local\Temp\e86ca78527dcfbd3cf\vs_bootstrapper_d15\HelpFile\1036\help.html...
Preparing: C:\Users\ContainerAdministrator\AppData\Local\Temp\e86ca78527dcfbd3cf\vs_bootstrapper_d15\HelpFile\3082\help.html...
Preparing: C:\Users\ContainerAdministrator\AppData\Local\Temp\e86ca78527dcfbd3cf\vs_bootstrapper_d15\HelpFile\1040\help.html...
Preparing: C:\Users\ContainerAdministrator\AppData\Local\Temp\e86ca78527dcfbd3cf\vs_bootstrapper_d15\HelpFile\1031\help.html...
Preparing: C:\Users\ContainerAdministrator\AppData\Local\Temp\e86ca78527dcfbd3cf\vs_bootstrapper_d15\HelpFile\1033\help.html...
Preparing: C:\Users\ContainerAdministrator\AppData\Local\Temp\e86ca78527dcfbd3cf\vs_bootstrapper_d15\HelpFile\1055\help.html...
Preparing: C:\Users\ContainerAdministrator\AppData\Local\Temp\e86ca78527dcfbd3cf\vs_bootstrapper_d15\HelpFile\1046\help.html...
Preparing: C:\Users\ContainerAdministrator\AppData\Local\Temp\e86ca78527dcfbd3cf\vs_bootstrapper_d15\HelpFile\1042\help.html...
Preparing: C:\Users\ContainerAdministrator\AppData\Local\Temp\e86ca78527dcfbd3cf\vs_bootstrapper_d15\HelpFile\1045\help.html...
Preparing: C:\Users\ContainerAdministrator\AppData\Local\Temp\e86ca78527dcfbd3cf\vs_bootstrapper_d15\HelpFile\1041\help.html...
Preparing: C:\Users\ContainerAdministrator\AppData\Local\Temp\e86ca78527dcfbd3cf\vs_bootstrapper_d15\HelpFile\1049\help.html...
Preparing: C:\Users\ContainerAdministrator\AppData\Local\Temp\e86ca78527dcfbd3cf\vs_bootstrapper_d15\vs_setup_bootstrapper.exe...
Preparing: C:\Users\ContainerAdministrator\AppData\Local\Temp\e86ca78527dcfbd3cf\vs_bootstrapper_d15\Microsoft.Diagnostics.Tracing.EventSource.dll...
Preparing: C:\Users\ContainerAdministrator\AppData\Local\Temp\e86ca78527dcfbd3cf\vs_bootstrapper_d15\Microsoft.VisualStudio.RemoteControl.dll...
Preparing: C:\Users\ContainerAdministrator\AppData\Local\Temp\e86ca78527dcfbd3cf\vs_bootstrapper_d15\Microsoft.VisualStudio.Setup.Common.dll...
Preparing: C:\Users\ContainerAdministrator\AppData\Local\Temp\e86ca78527dcfbd3cf\vs_bootstrapper_d15\Microsoft.VisualStudio.Setup.Configuration.Interop.dll...
Preparing: C:\Users\ContainerAdministrator\AppData\Local\Temp\e86ca78527dcfbd3cf\vs_bootstrapper_d15\Microsoft.VisualStudio.Setup.dll...
Preparing: C:\Users\ContainerAdministrator\AppData\Local\Temp\e86ca78527dcfbd3cf\vs_bootstrapper_d15\Microsoft.VisualStudio.Setup.Download.dll...
Preparing: C:\Users\ContainerAdministrator\AppData\Local\Temp\e86ca78527dcfbd3cf\vs_bootstrapper_d15\Microsoft.VisualStudio.Setup.Engine.dll...
Preparing: C:\Users\ContainerAdministrator\AppData\Local\Temp\e86ca78527dcfbd3cf\vs_bootstrapper_d15\Microsoft.VisualStudio.Telemetry.dll...
Preparing: C:\Users\ContainerAdministrator\AppData\Local\Temp\e86ca78527dcfbd3cf\vs_bootstrapper_d15\Microsoft.VisualStudio.Utilities.Internal.dll...
Preparing: C:\Users\ContainerAdministrator\AppData\Local\Temp\e86ca78527dcfbd3cf\vs_bootstrapper_d15\Newtonsoft.Json.dll...
Preparing: C:\Users\ContainerAdministrator\AppData\Local\Temp\e86ca78527dcfbd3cf\vs_bootstrapper_d15\zh-Hans\vs_setup_bootstrapper.resources.dll...
Preparing: C:\Users\ContainerAdministrator\AppData\Local\Temp\e86ca78527dcfbd3cf\vs_bootstrapper_d15\zh-Hant\vs_setup_bootstrapper.resources.dll...
Preparing: C:\Users\ContainerAdministrator\AppData\Local\Temp\e86ca78527dcfbd3cf\vs_bootstrapper_d15\cs\vs_setup_bootstrapper.resources.dll...
Preparing: C:\Users\ContainerAdministrator\AppData\Local\Temp\e86ca78527dcfbd3cf\vs_bootstrapper_d15\pt-BR\vs_setup_bootstrapper.resources.dll...
Preparing: C:\Users\ContainerAdministrator\AppData\Local\Temp\e86ca78527dcfbd3cf\vs_bootstrapper_d15\tr\vs_setup_bootstrapper.resources.dll...
Preparing: C:\Users\ContainerAdministrator\AppData\Local\Temp\e86ca78527dcfbd3cf\vs_bootstrapper_d15\es\vs_setup_bootstrapper.resources.dll...
Preparing: C:\Users\ContainerAdministrator\AppData\Local\Temp\e86ca78527dcfbd3cf\vs_bootstrapper_d15\de\vs_setup_bootstrapper.resources.dll...
Preparing: C:\Users\ContainerAdministrator\AppData\Local\Temp\e86ca78527dcfbd3cf\vs_bootstrapper_d15\fr\vs_setup_bootstrapper.resources.dll...
Preparing: C:\Users\ContainerAdministrator\AppData\Local\Temp\e86ca78527dcfbd3cf\vs_bootstrapper_d15\it\vs_setup_bootstrapper.resources.dll...
Preparing: C:\Users\ContainerAdministrator\AppData\Local\Temp\e86ca78527dcfbd3cf\vs_bootstrapper_d15\pl\vs_setup_bootstrapper.resources.dll...
Preparing: C:\Users\ContainerAdministrator\AppData\Local\Temp\e86ca78527dcfbd3cf\vs_bootstrapper_d15\ko\vs_setup_bootstrapper.resources.dll...
Preparing: C:\Users\ContainerAdministrator\AppData\Local\Temp\e86ca78527dcfbd3cf\vs_bootstrapper_d15\ja\vs_setup_bootstrapper.resources.dll...
Preparing: C:\Users\ContainerAdministrator\AppData\Local\Temp\e86ca78527dcfbd3cf\vs_bootstrapper_d15\ru\vs_setup_bootstrapper.resources.dll...
Preparing: C:\Users\ContainerAdministrator\AppData\Local\Temp\e86ca78527dcfbd3cf\vs_bootstrapper_d15\vs_setup_bootstrapper.config...
Preparing: C:\Users\ContainerAdministrator\AppData\Local\Temp\e86ca78527dcfbd3cf\vs_bootstrapper_d15\vs_setup_bootstrapper.exe.config...
Preparing: C:\Users\ContainerAdministrator\AppData\Local\Temp\e86ca78527dcfbd3cf\vs_bootstrapper_d15\detection.json...
Preparing: C:\Users\ContainerAdministrator\AppData\Local\Temp\e86ca78527dcfbd3cf\vs_bootstrapper_d15\vs_setup_bootstrapper.json...
The command 'cmd /S /C C:\\tmp\\vs-build-tools.exe --add Microsoft.VisualStudio.Workload.VCTools --includeRecommended --quiet --passive --norestart --wait --nocache' returned a non-zero code: 5003
我注意到this Github user遇到了类似的问题,尽管还没有给出答案。
我还读过MS开发者社区上的this post,那里的人们似乎建议使用旧版本或较新版本的windosservercore映像(This blog post似乎也提供类似的建议)。这就是为什么我使用10.0.14393.1480
的原因,但不幸的是没有用。
答案 0 :(得分:4)
我一直使用非零代码1作为退出代码,所有内容都与您拥有的代码非常相似,这让我感到困惑。
帮助我的是将与RUN C:\\tmp\\vs-build-tools.exe --add Microsoft.VisualStudio.Workload.VCTools --includeRecommended --quiet --passive --norestart --wait --nocache
对应的行更改为:
RUN C:\\tmp\\vs-build-tools.exe --add Microsoft.VisualStudio.Workload.VCTools --includeRecommended --quiet --passive --norestart --wait --nocache || exit 0
即使失败,也会报告退出代码0。尽管我完全意识到这通常是一个非常糟糕的主意,但是当我运行docker run -it build-container cmd
时,我发现构建工具已正确安装。
否则,我也可以推荐Microsoft here描述的方法来从安装中收集日志。以后可以将日志提交给Microsoft以获取支持。
您可能需要解决的方法是通过Chocolatey安装构建工具。我以前一直在使用以下程序,我相信您可以找到满足您需求的类似软件包:
RUN choco install -y visualstudio2017community --version 15.9.7.0
RUN choco install -y visualstudio2017-workload-nativedesktop
RUN choco install -y visualcpp-build-tools