vpext/vs-buildtools-cpp
A basic image that provides build tools for C++ builds within a docker container.
112
This is an image based on windows/servercore (and others) that installs the v143 C++ build tools into C:\BuildTools
.
Name | Base |
---|---|
servercore-2019 | mcr.microsoft.com/windows/servercore:ltsc2019 |
servercore-2022 | mcr.microsoft.com/windows/servercore:ltsc2022 |
base-2019 | mcr.microsoft.com/windows:ltsc2022 |
# escape=`
ARG BASE_IMAGE
FROM ${BASE_IMAGE}
ADD https://aka.ms/vscollect.exe C:\TEMP\collect.exe
ADD https://aka.ms/vs/17/release/channel C:\TEMP\VisualStudio.chman
ADD https://aka.ms/vs/17/release/vs_buildtools.exe C:\TEMP\vs_buildtools.exe
COPY Install.cmd C:\TEMP\
COPY InstallScript.ps1 C:\
SHELL ["powershell", "-command"]
RUN C:\InstallScript.ps1
RUN Remove-Item C:\InstallScript.ps1
SHELL ["cmd", "/S", "/C"]
ENTRYPOINT ["C:\\BuildTools\\Common7\\Tools\\VsDevCmd.bat", "&&", "powershell.exe", "-NoLogo", "-ExecutionPolicy", "Bypass"]
Write-Host ">> Updating Visual Studio Build Tools ..."
$buildTools = Start-Process "C:\TEMP\Install.cmd" `
-ArgumentList "C:\TEMP\vs_buildtools.exe", `
"--wait", "--quiet", "--norestart", "--nocache", `
"--channelUri", "C:\TEMP\VisualStudio.chman", `
"--installChannelUri", "C:\TEMP\VisualStudio.chman", `
"--locale", "en-US", `
"--installPath", "C:\BuildTools", `
"--add Microsoft.VisualStudio.Workload.VCTools", `
"--add Microsoft.VisualStudio.Component.VC.ATL", `
"--add Microsoft.VisualStudio.Component.VC.ATLMFC", `
"--includeRecommended", `
"--remove Microsoft.VisualStudio.Component.VC.ASAN", `
"--remove Microsoft.VisualStudio.Component.VC.CMake.Project" `
-NoNewWindow `
-PassThru `
-Wait
Write-Host (">> Visual Studio Build tools exited with error code {0}." -f $buildTools.ExitCode)
if ($buildTools.ExitCode -eq 3010) {
Write-Host ">> [!] Container requires a reboot, which is impossible. Report an issue to Microsoft."
}
exit $buildTools.ExitCode
@rem Copyright (C) Microsoft Corporation. All rights reserved.
@rem Licensed under the MIT license. See LICENSE.txt in the project root for license information.
@if not defined _echo echo off
setlocal enabledelayedexpansion
call %*
if "%ERRORLEVEL%"=="3010" (
exit /b 0
) else (
if not "%ERRORLEVEL%"=="0" (
set ERR=%ERRORLEVEL%
call C:\TEMP\collect.exe -zip:C:\vslogs.zip
exit /b !ERR!
)
)
Using GitHub Actions
name: Build and deploy to Docker Hub
on:
workflow_dispatch:
inputs:
runnerName:
type: choice
required: true
options:
- "2022"
- "2019"
description: "Version of the runner that will execute the build"
baseImageName:
type: choice
required: true
options:
- "windows"
- "windows/servercore"
- "windows/server"
description: "The name of the base image of this build"
extraTag:
type: text
required: false
description: "Base name of the tag"
default: "base"
jobs:
docker-build:
runs-on: windows-${{ inputs.runnerName }}
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Build image and push to registry
id: docker_build
uses: mr-smithers-excellent/docker-build-push@v5
with:
image: vpext/vs-buildtools-cpp
tags: ${{ inputs.extraTag }}-${{ inputs.runnerName }}
registry: docker.io
platform: windows/amd64
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
buildArgs: "BASE_IMAGE=mcr.microsoft.com/${{ inputs.baseImageName }}:ltsc${{ inputs.runnerName }}"
docker pull vpext/vs-buildtools-cpp