Skip to content

Instantly share code, notes, and snippets.

@adujardin
Created July 12, 2021 13:06
Show Gist options
  • Save adujardin/65a54338801e6fb505994af254221f76 to your computer and use it in GitHub Desktop.
Save adujardin/65a54338801e6fb505994af254221f76 to your computer and use it in GitHub Desktop.
Windows docker VCTools 2019
# escape=`
# References:
# https://docs.microsoft.com/en-us/visualstudio/install/build-tools-container?view=vs-2019
# https://github.com/microsoft/vs-dockerfiles/blob/main/native-desktop/Dockerfile
FROM mcr.microsoft.com/dotnet/framework/sdk:4.8-windowsservercore-ltsc2019
# Restore the default Windows shell for correct batch processing.
SHELL ["cmd", "/S", "/C"]
# Download collect.exe in case of an install failure.
ADD https://aka.ms/vscollect.exe C:\TEMP\collect.exe
# Use the latest release channel. For more control, specify the location of an internal layout.
ARG CHANNEL_URL=https://aka.ms/vs/16/release/channel
ADD ${CHANNEL_URL} C:\TEMP\VisualStudio.chman
RUN `
# Download the Build Tools bootstrapper.
curl -SL --output vs_buildtools.exe https://aka.ms/vs/16/release/vs_buildtools.exe `
`
# Install Build Tools
&& (start /w vs_buildtools.exe --quiet --wait --norestart --nocache modify`
--installPath "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools" `
--channelUri C:\TEMP\VisualStudio.chman `
--installChannelUri C:\TEMP\VisualStudio.chman `
--add Microsoft.VisualStudio.Workload.VCTools --includeRecommended `
|| IF "%ERRORLEVEL%"=="3010" EXIT 0) `
`
# Cleanup
&& del /q 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:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\BuildTools\\Common7\\Tools\\VsDevCmd.bat", "&&", "powershell.exe", "-NoLogo", "-ExecutionPolicy", "Bypass"]
#ENTRYPOINT ["powershell.exe", "-NoLogo", "-ExecutionPolicy", "Bypass"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment