title: Installation of MS Build Tools fails on Windows Docker Container
body: <p>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.</p>
  
  <p><em>Note: I do not intend to use any part of the .NET framework for my project</em></p>
  
  <p>Unfortunately, the installation of MS Build Tools in my Docker container fails with an exit code of 5003 and no error message.</p>
  
  <p>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?</p>
  
  <p>My Dockerfile looks like this:</p>
  
  <pre><code>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 &amp;&amp;
  CMD ["powershell.exe", "-NoLogo", "-ExecutionPolicy", "Bypass"]
  </code></pre>
  
  <p>And I'm building the container with this batch script (Username has been replaced):</p>
  
  <pre><code>docker image rm someusername/cmake-msvc
  docker build -t someusername/cmake-msvc -m 8g .
  docker push someusername/cmake-msvc
  </code></pre>
  
  <p>I've read that <a href="https://github.com/Microsoft/vsts-agent-docker/issues/46" rel="noreferrer">these Windows containers require</a> <a href="https://docs.microsoft.com/en-us/visualstudio/install/build-tools-container-issues?view=vs-2019" rel="noreferrer">a large amount of storage space</a>, so I've increased the available space by setting <code>storage-opts</code>:</p>
  
  <pre><code>"storage-opts": [
      "size=120G"
  ]
  </code></pre>
  
  <p>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):</p>
  
  <pre><code>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
   ---&gt; 2c42a1b4dea8
  Step 2/7 : ADD https://aka.ms/vs/15/release/vs_buildtools.exe   C:\\tmp\\vs-build-tools.exe
  Downloading [==================================================&gt;]  1.286MB/1.286MB
  
   ---&gt; 1891bae28aa1
  Step 3/7 : RUN C:\\tmp\\vs-build-tools.exe --add Microsoft.VisualStudio.Workload.VCTools --includeRecommended --quiet --passive --norestart --wait --nocache
   ---&gt; 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
  </code></pre>
  
  <p>I've noticed that <a href="https://github.com/Microsoft/vs-dockerfiles/issues/5" rel="noreferrer">this Github user</a> is experiencing a similar issue, although no answer has been given yet.
  I've also read <a href="https://developercommunity.visualstudio.com/content/problem/81514/2017-build-tools-fails-to-install-on-windows-serve.html" rel="noreferrer">this post</a> on the MS Developer Community, where people seem to recommend using an older or a newer version of the windosservercore image (<a href="https://devblogs.microsoft.com/setup/installing-build-tools-for-visual-studio-2017-in-a-docker-container/" rel="noreferrer">This blog post</a> seems to give similar recommendations). That's why I'm using <code>10.0.14393.1480</code>, but unfortunately to no avail.</p>