I’m trying to build a minimal image to allow compilation in Windows via the Visual Studio build tools. (basically, Install Visual Studio Build Tools into a container to support a consistent build system | Microsoft Learn)
I’ve been working through various issues, but seem to be blocked now. I’ve a feeling the the Docker cache has gotten into a bad state, but the --no-cache option doesn’t seem to help.
Script at end.
docker build --no-cache -t vs/buildtools:latest -m 16GB .
Gets the following in the log, and then hangs. I have to press ctrl-c to exit
---> Running in f2c6fdde6ad4
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
100 3863k 100 3863k 0 0 6500k 0 --:--:-- --:--:-- --:--:-- 6500k
The same thing happens if I comment in the second curl command in the script. Or the normal script after I ran with --no-cache.
Cheers
John
# escape=`
# Use the latest Windows Server Core 2022 image.
FROM mcr.microsoft.com/windows/servercore:ltsc2022
# Restore the default Windows shell for correct batch processing.
SHELL ["cmd", "/S", "/C"]
RUN `
# Download the Build Tools bootstrapper.
curl -SL --output vs_buildtools.exe https://aka.ms/vs/17/release/vs_buildtools.exe `
`
# Install Build Tools with the Microsoft.VisualStudio.Workload.AzureBuildTools workload, excluding workloads and components with known issues.
&& (start /w vs_buildtools.exe --quiet --wait --norestart --nocache `
--installPath "%ProgramFiles%\Microsoft Visual Studio\2022\BuildTools" `
--add Microsoft.VisualStudio.Component.TestTools.BuildTools `
--add Microsoft.VisualStudio.Component.VC.CMake.Project `
--add Microsoft.VisualStudio.Component.VC.Tools.x86.x64 `
--add Microsoft.Net.Component.4.8.SDK `
--add Microsoft.VisualStudio.Component.VC.ATL `
--add Microsoft.VisualStudio.Component.VC.ATLMFC `
--add Microsoft.VisualStudio.Component.VC.CLI.Support `
--add Microsoft.VisualStudio.Component.VC.Llvm.Clang `
--add Microsoft.VisualStudio.Component.VC.Llvm.ClangToolset `
--add Microsoft.VisualStudio.ComponentGroup.NativeDesktop.Llvm.Clang `
--remove Microsoft.VisualStudio.Component.Windows10SDK.14393 `
--remove Microsoft.VisualStudio.Component.Windows10SDK.15063 `
--remove Microsoft.VisualStudio.Component.Windows10SDK.16299 `
--remove Microsoft.VisualStudio.Component.Windows10SDK.17134 `
--add Microsoft.VisualStudio.Component.Windows11SDK.22621 `
|| IF "%ERRORLEVEL%"=="3010" EXIT 0) `
`
# Cleanup
&& del /q vs_buildtools.exe `
# Install nuget
# curl -SL --output nuget.exe https://dist.nuget.org/win-x86-commandline/latest/nuget.exe `
# Install git for windows
# && nuget install Git-Windows-Minimal -Version 2.43.0
# This should be the default user for servercore but not nanoserver
# USER ContainerAdministrator
# Define the entry point for the docker container.
# This entry point starts the developer command prompt and launches the PowerShell shell.
# ENTRYPOINT ["C:\\Program Files\\Microsoft Visual Studio\\2022\\BuildTools\\Common7\\Tools\\VsDevCmd.bat", "-arch=amd64"]