September 18th, 2017

Installing Build Tools for Visual Studio 2017 in a Docker container

Heath Stewart
Principal Software Engineer

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%\vslogs.zip 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\vslogs.zip "%TEMP%\vslogs.zip"

The install logs like dd_setup_*_errors.log will have more details, and if there isn’t already an issue on https://developercommunity.visualstudio.com please open one with vslogs.zip attached.

Author

Heath Stewart
Principal Software Engineer

Heath is an application architect and developer, looking to help educate others to learn professional development. Besides designing and developing applications he enjoys writing about intermediate and advanced topics. Heath also consults for deployment packages and scenarios within Microsoft and for external customers.

2 comments

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

  • Kiran Hegde

    Hello Heath,
    I am using a container based on  mcr.microsoft.com/windows:1809 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: https://habr.com/en/company/infopulse/blog/271809/
    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...

    Read more
    • Heath StewartMicrosoft employee Author

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