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.
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.
On
Just for the record MS is not planning support VS inside containers, the best alternative that you have is MsBuild. Some months ago was possible but with the latest version from VS is not possible. Source: vsts-agents
On
A way to install visual build chain in a windows container could be to use chocolatey package visualstudio2017buildtools.
Starting Dockerfile with something like :
FROM microsoft/windowsservercore
RUN powershell.exe -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SETX PATH "%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"
RUN choco install -y visualstudio2017buildtools --package-parameters "--add Microsoft.VisualStudio.Workload.VCTools --installPath C:\BuildTools" || IF "%ERRORLEVEL%"=="3010" EXIT 0
RUN call "C:\BuildTools\VC\Auxiliary\Build\vcvars64.bat"
On
I've recently spent a lot of time investigating this as our goal was to set up "dockerized" DevOps agents which were capable of running the VsBuild@1 pipeline task (among other things).
Generally, if you DON'T need VsBuild@1 (or some of the other tasks related to Visual Studio, like VsTest@2 or the like) then you're better of using https://hub.docker.com/_/microsoft-dotnet-framework-sdk/ as your base and call it a day; those images come with the Build Tools and VS Test agent already installed.
However it IS possible to install VS. Some notes:
%windir%\Microsoft.NET\Framework64\v4.0.30319\ngen update. Do note that with a VS installation inside Docker this WILL fail in various ways, so you'll need to find ways around this.DockerFile for the SDK images for some references; specifically interesting is the manual installation of .NET Framework targetting packs: https://github.com/microsoft/dotnet-framework-docker/blob/main/src/sdk/4.8.1/windowsservercore-ltsc2022/Dockerfile
(Should this link ever stop working because the file is moved then it's worth taking a look at the DockerFiles in the https://github.com/microsoft/dotnet-framework-docker repo)--add arguments.
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:
(I'm pushing this image into lukaslansky/visualstudio-netwebworkload, use with caution.)
Output of the build is:
So this seems to work! You should play with those
--addinstallator 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.