Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Installation of MS Build Tools fails on Windows Docker Container

I'm trying to set up a Windows container for a CI pipeline. My Project uses C++ and CMake, so I'm using the Microsoft Build Tools installer.

Note: I do not intend to use any part of the .NET framework for my project

Unfortunately, the installation of MS Build Tools in my Docker container fails with an exit code of 5003 and no error message.

I haven't been able to find an explanation of this return code. I was wondering if anyone could tell me what I'm doing wrong?

My Dockerfile looks like this:

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"]

And I'm building the container with this batch script (Username has been replaced):

docker image rm someusername/cmake-msvc
docker build -t someusername/cmake-msvc -m 8g .
docker push someusername/cmake-msvc

I've read that these Windows containers require a large amount of storage space, so I've increased the available space by setting storage-opts:

"storage-opts": [
    "size=120G"
]

This is the console output I get when building, it takes a while before the build crashes (I haven't timed it, but I'm guessing it's somewhere between 20 and 40 minutes):

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

I've noticed that this Github user is experiencing a similar issue, although no answer has been given yet. I've also read this post on the MS Developer Community, where people seem to recommend using an older or a newer version of the windosservercore image (This blog post seems to give similar recommendations). That's why I'm using 10.0.14393.1480, but unfortunately to no avail.

like image 567
shmoo6000 Avatar asked Apr 15 '19 20:04

shmoo6000


1 Answers

I've been having the non-zero code 1 as an exit code, with everything quite similar to how you have it, and it had me quite baffled.

What helped me was to change the line corresponding to RUN C:\\tmp\\vs-build-tools.exe --add Microsoft.VisualStudio.Workload.VCTools --includeRecommended --quiet --passive --norestart --wait --nocache into:

RUN C:\\tmp\\vs-build-tools.exe --add Microsoft.VisualStudio.Workload.VCTools --includeRecommended --quiet --passive --norestart --wait --nocache || exit 0

Which reports an exit code of 0 even when it fails. While I am fully aware that this is in general a very bad idea, when I run docker run -it build-container cmd I see that my build tools have been installed correctly.

Edit:

You might want to run this aswell, to install any SDK-packages that were not installed by VS2017 (you can download the SDK from Microsoft's website):

RUN powershell -NoProfile -ExecutionPolicy Bypass -Command Start-Process -FilePath "C:\tmp\winsdksetup_17763.exe" -ArgumentList '/Quiet /NoRestart' -Wait

Otherwise I can also recommend the method described by Microsoft here to collect logs from the installation. The logs can later on be submitted to Microsoft to get support.

A possible work-around for you is to install the build-tools via Chocolatey. I've been previously using the following, I'm sure you can find similar packages to meet your needs:

RUN choco install -y visualstudio2017community --version 15.9.7.0
RUN choco install -y visualstudio2017-workload-nativedesktop
RUN choco install -y visualcpp-build-tools
like image 170
Oleg Avatar answered Oct 20 '22 18:10

Oleg