Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to install Visual Studio in a Windows Container

Is it possible to install any version of Visual Studio in a Windows Container on a Windows Server?

The motivation is to use Windows Containers for building software in continuous integration systems, so that the build environment is standardized.

like image 929
Jifeng Zhang Avatar asked Dec 22 '16 07:12

Jifeng Zhang


People also ask

Can Visual Studio run in a container?

In Visual Studio 2019 version 16.4 and later, the Containers window is available, which lets you view running containers, browse available images, view environment variables, logs, and port mappings, inspect the filesystem, attach a debugger, or open a terminal window inside the container environment.

Can I run Visual Studio in a Docker container?

Visual Studio provides a consistent way to develop Docker containers and validate your application locally. You can run and debug your apps in Linux or Windows containers running on your local Windows desktop with Docker installed, and you don't have to restart the container each time you make a code change.

Can I run Windows in a container?

Windows 10 with Anniversary Update For developers, Windows 10 is a great place to run Docker Windows containers and containerization support was added to the the Windows 10 kernel with the Anniversary Update (note that container images can only be based on Windows Server Core and Nanoserver, not Windows 10).

Can I run any application in a container?

You can run any application in Docker as long as it can be installed and executed unattended, and the base operating system supports the app. Windows Server Core runs in Docker which means you can run pretty much any server or console application in Docker.


1 Answers

Visual Studio seems to not be supported officially on Core Server, but I agree it would be really nice to be able to do this. Let's try:

FROM mcr.microsoft.com/windows/servercore:ltsc2019 SHELL ["powershell"]  RUN Invoke-WebRequest "https://aka.ms/vs/16/release/vs_community.exe" -OutFile "$env:TEMP\vs_community.exe" -UseBasicParsing RUN & "$env:TEMP\vs_community.exe" --add Microsoft.VisualStudio.Workload.NetWeb --quiet --wait --norestart --noUpdateInstaller | Out-Default  RUN & 'C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/MSBuild/15.0/Bin/MSBuild.exe' /version  CMD ["powershell"] 

(I'm pushing this image into lukaslansky/visualstudio-netwebworkload, use with caution.)

Output of the build is:

[...] Microsoft (R) Build Engine version 15.3.409.57025 for .NET Framework Copyright (C) Microsoft Corporation. All rights reserved. 

So this seems to work! You should play with those --add installator arguments to specify what components you need precisely for your build, they correspond to workloads and components you see in the GUI. See the documentation.

like image 152
Lukáš Lánský Avatar answered Sep 22 '22 12:09

Lukáš Lánský