It is possible to use Visual Studio 2026 Build Tools (MSBuild 18 / MSVC v145) on GitHub-hosted Windows runners, even though they are not preinstalled.
GitHub-hosted Windows runners include Chocolatey out of the box, which allows you to install additional toolchains at runtime during the workflow.
Using Chocolatey, you can install Visual Studio 2026 Build Tools side-by-side with the preinstalled Visual Studio 2022 Build Tools (MSBuild 17 / MSVC v143).
In a GitHub Actions workflow YAML file (for example, .github/workflows/static_code_analisys.yml), you can install Visual Studio 2026 Build Tools & configure configure it explicitly:
Install
- name: Install Visual Studio Build Tools
shell: pwsh
run: |
Write-Host "Installing VS 2026 Build Tools..."
choco install visualstudio2026buildtools `
--package-parameters "--add Microsoft.VisualStudio.Workload.VCTools --add Microsoft.VisualStudio.Component.VC.Tools.x86.x64 --includeRecommended --quiet" `
-y --ignore-package-exit-codes=3010
Write-Host "VS 2026 Build Tools installation completed"
Handling exit code 3010:
Visual Studio installers often return 3010:
✅ Installation succeeded
⚠️ Reboot requested
Fortunately, for command-line C++ builds, the compiler and MSBuild are usable immediately after installation. Using --ignore-package-exit-codes=3010 allows the pipeline to continue safely without sacrificing correctness.
Configure & Build
To ensure the VS 2026 toolchain is used (and not the preinstalled VS 2022 tools), explicitly initialize the environment from the VS 2026 installation:
- name: Build project (${{ matrix.config }}, x64, C++latest)
shell: cmd
run: |
call "C:\Program Files (x86)\Microsoft Visual Studio\18\BuildTools\Common7\Tools\VsDevCmd.bat"
echo Building solution (${{ matrix.config }}, x64) with C++latest standard...
echo Using solution file: %SOLUTION_FILE%
msbuild /m ^
/p:Configuration=${{ matrix.config }} ^
/p:Platform=x64 ^
/p:LanguageStandard=stdcpplatest ^
/fl /flp:logfile=msbuild.log ^
%SOLUTION_FILE%
⚠️ Hardcoding C:\Program Files (x86)\Microsoft Visual Studio\18\BuildTools\Common7\Tools\VsDevCmd.bat ensures VS 2026 is used
✅ msbuild 18 is ready for use.
Full example
The static_code_analisys.yml (section 6 & 7) and the workflow run.