Windows-Containers
Windows-Containers copied to clipboard
Cannot install Visual Studio inside a server core image
Describe the bug I am trying to install VS 2022 build tools inside of a docker container to build an image and use it for our CI builds. I already had an image working, but now I needed to update a dependency so I had to rebuild it (TL; DR: it worked last time I built it).
However, the installation now fails with error code 1603.
I have extracted the VS installation logs from the container and the main issue seems to be this:
Error Information
AppInsightsEvent Name = vs/setupengine/packagefailure
Description = The Windows Installer Service could not be accessed. This can occur if the Windows Installer is not correctly installed. Contact your support personnel for assistance.
TelemetrySession = 'aa0725d0-d978-4bf5-bd3c-8f68d3d9702f' Started = True OptIn=True IsInitialized = False Cloned = True
WatsonEventType = VisualStudioNonFatalErrors2
UTC time = 2024-09-26T12:17:52
I run an sfc /scannow
inside brand new container using the image and it did find some corrupted files, so maybe the image itself has issues?
To Reproduce You should be able to reproduce this by building the following Dockerfile (based on the example here, where you can also find the Install.cmd file contents):
# escape=`
# Use the Windows Server Core as base image
FROM mcr.microsoft.com/windows/servercore:ltsc2019
SHELL ["cmd", "/S", "/C"]
COPY Install.cmd C:\TEMP\
ADD https://aka.ms/vscollect.exe C:\TEMP\collect.exe
ADD https://aka.ms/vs/17/release/channel C:\TEMP\VisualStudio.chman
RUN curl -SL --output vs_buildtools.exe https://aka.ms/vs/17/release/vs_buildtools.exe `
&& (call C:\TEMP\Install.cmd vs_buildtools.exe --quiet --wait --norestart --nocache install `
--installPath "%ProgramFiles(x86)%\Microsoft Visual Studio\2022\BuildTools" `
--channelUri C:\TEMP\VisualStudio.chman `
--installChannelUri C:\TEMP\VisualStudio.chman `
--add Microsoft.VisualStudio.Workload.MSBuildTools `
--add Microsoft.VisualStudio.Workload.ManagedDesktopBuildTools `
--add Microsoft.VisualStudio.Workload.VCTools `
--add Microsoft.VisualStudio.Component.Windows11SDK.22000 `
--add Microsoft.VisualStudio.Component.VC.Tools.x86.x64 `
--add Microsoft.VisualStudio.Component.VC.ATLMFC) `
&& del /q vs_buildtools.exe
ENTRYPOINT ["C:\\Program Files (x86)\\Microsoft Visual Studio\\2022\\BuildTools\\Common7\\Tools\\VsDevCmd.bat", "&&", "powershell.exe", "-NoLogo", "-ExecutionPolicy", "Bypass"]
Expected behavior The image builds without issues.
Configuration:
- Edition: Windows Server
- Base Image being used:
mcr.microsoft.com/windows/servercore:ltsc2019
- Container engine: Docker
- Container Engine version: 20.10.15