Installing Build Tools for Visual Studio 2017 in a Docker container

Heath Stewart

Docker containers are a lightweight alternative to full virtual machines that abstract the file system of the host operating system but are otherwise isolated. While popular for service deployments as a complete means of acquisition, containers are also useful for isolating build and test environments.

You can install Visual Studio 2017 and the Build Tools into a Docker container using the command line interactively or using a _Dockerfile_ such as the example below.

We are tracking and working to resolve some issues customers have reported and that we have also experienced. What follows is not comprehensive but some of the more common issues people are experiencing.

  • Installing Visual Studio 2013, 2015, or 2017 on microsoft/windowsservercore:10.0.14393.1593 (which may be your locally cached :latest depending on when you last pulled) fails. The bootstrapper fails to launch the installer. Please use either an older tagged build like :10.0.14393.1480 or newer tagged build like :10.0.14393.1715 – the current :latest when this post was first published.
  • When using PowerShell as your SHELL, the Start-Process cmdlets may not set $LASTEXITCODE or $?. This is not a problem with the bootstrapper, but does require a workaround like: $p = start-process -wait -passthru -file c:\vs_buildtools.exe -args '--installPath c:\build'; if ($p.ExitCode) { throw ("Install failed: 0x{0:x}" -f $p.ExitCode) }

In the example above, any failures to install the selected workloads are captured in the container’s %TEMP%\ so if you find the container ID in which the command was running (it will be printed right after the command that will run, like ” —> Running in 55e4baeceea1″), you can copy it out of a stopped container.

docker cp 55e4baeceea1:C:\Users\ContainerAdministrator\AppData\Local\Temp\ "%TEMP%\"

The install logs like dd_setup_*_errors.log will have more details, and if there isn’t already an issue on please open one with attached.


Discussion is closed. Login to edit/delete existing comments.

  • Kiran Hegde 0

    Hello Heath,
    I am using a container based on to perform a silent installation of  VS2015 Enterprise Update 3.  Unfortunately, the installation fails. I could successfully install Visual Studio Professional 2013 on this container.
    The problem i am facing is very similar to what has been described at:
    I inspected the event viewer on the Docker container and the exact same set of components that are reported as failing in the screenshot in the above url, are also failing on the Docker container. The failures with each of the installers seems to be with trying to install extensions(.vsix ) using VsixInstaller.exe
    You can find the installation logs at:
    This seems to be a very common issue and not just limited to containers.  I can successfully install the very same Visual Studio 2015 on Windows 2016/Win10. Kindly suggest what could be done to resolve this issue.
    We are trying to set up a developer build envionrment on Docker containers and it is very essential that we solve this issue.
    I have also used the windowsservercore:ltsc2019 image and unfortunately, that has issues installing VS2013 as well.
    Should i be switching over to start using the build tools for VS2015? Kindly advice.

    • Heath StewartMicrosoft employee 0

      Please open a feedback ticket with logs collected from within the container so we can investigate.

Feedback usabilla icon