I created msbuild:ltsc2016 docker image using the following dockerfile:
# escape=`
FROM mcr.microsoft.com/dotnet/framework/runtime:4.8-windowsservercore-ltsc2016
# Restore the default Windows shell for correct batch processing.
SHELL ["cmd", "/S", "/C"]
# Download the Build Tools bootstrapper.
ADD https://aka.ms/vs/16/release/vs_buildtools.exe C:\TEMP\vs_buildtools.exe
# Install Build Tools with the Microsoft.VisualStudio.Workload.AzureBuildTools workload, excluding workloads and components with known issues.
RUN C:\TEMP\vs_buildtools.exe --quiet --wait --norestart --nocache `
--installPath C:\BuildTools `
--includeRecommended `
--add Microsoft.VisualStudio.Workload.ManagedDesktopBuildTools `
--add Microsoft.VisualStudio.Workload.MSBuildTools `
--add Microsoft.VisualStudio.Workload.VCTools `
|| IF "%ERRORLEVEL%"=="3010" EXIT 0
RUN del C:\TEMP\vs_buildtools.exe
# Define the entry point for the docker container.
# This entry point starts the developer command prompt and launches the PowerShell shell.
# ENTRYPOINT ["C:\\BuildTools\\Common7\\Tools\\VsDevCmd.bat", "&&", "powershell.exe", "-NoLogo", "-ExecutionPolicy", "Bypass"]
And then I created an image for Rust MSVC:
# escape=`
FROM msbuild:ltsc2016
ADD https://win.rustup.rs C:\TEMP\rustup-init.exe
RUN C:\TEMP\rustup-init.exe -y -v --default-toolchain stable-x86_64-pc-windows-msvc
RUN del C:\TEMP\rustup-init.exe
Both dockerfiles build just fine. But there's a problem: when I try to build anything using rust-msvc, Rust errors about link.exe not being found. So it find out, Rust cannot find VS Build Tools, even though they are installed.
I tried to workaround this by adding the following file to C:\Users\ContainerAdministrator\.cargo\config: