GitHub Action
The action consumes query JSON as its environment source and validates selected tools with a compile probe. host-arch is forwarded through acquisition and query. Cross-compilation requires a CLI supporting host selection; unsupported older releases fail clearly. MSVC-only and SDK-only outputs omit the other component.
Release bootstrap discovers the actual executable asset in GitHub release metadata and checks its SHA256 digest. msvc-kit-path can select an explicitly trusted executable, including a source build. vs-channel selects package discovery and lockfile enables exact selection/source verification with a capable CLI. See toolchain contracts.
msvc-kit provides an official GitHub Action for easily setting up the MSVC build environment in CI/CD pipelines.
Basic Usage
name: Build
on: [push, pull_request]
jobs:
build:
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- name: Setup MSVC Build Tools
uses: loonghao/msvc-kit@v1
with:
arch: x64
- name: Build
run: |
cl /nologo test.cSpecific Versions
- name: Setup MSVC Build Tools
uses: loonghao/msvc-kit@v1
with:
msvc-version: "14.44"
sdk-version: "10.0.26100.0"
arch: x64Matrix Build
name: Matrix Build
on: [push]
jobs:
build:
runs-on: windows-latest
strategy:
matrix:
arch: [x64, x86, arm64]
steps:
- uses: actions/checkout@v4
- name: Setup MSVC Build Tools
id: msvc
uses: loonghao/msvc-kit@v1
with:
arch: ${{ matrix.arch }}
- name: Show installed versions
run: |
echo "MSVC: ${{ steps.msvc.outputs.msvc-version }}"
echo "SDK: ${{ steps.msvc.outputs.sdk-version }}"
echo "cl.exe: ${{ steps.msvc.outputs.cl-path }}"With Caching
- name: Cache MSVC
uses: actions/cache@v4
with:
path: ${{ steps.msvc.outputs.install-dir }}
key: msvc-${{ matrix.arch }}-${{ steps.msvc.outputs.msvc-version }}
- name: Setup MSVC Build Tools
id: msvc
uses: loonghao/msvc-kit@v1
with:
arch: ${{ matrix.arch }}Rust + cc-rs Integration
The action automatically sets CC and CXX environment variables for seamless Rust/cc-rs compatibility:
- name: Setup MSVC Build Tools
uses: loonghao/msvc-kit@v1
with:
arch: x64
- name: Build Rust project with C dependencies
run: cargo build --releaseInputs
| Input | Description | Default |
|---|---|---|
msvc-version | MSVC version (empty = latest) | "" |
sdk-version | Windows SDK version (empty = latest) | "" |
arch | Target architecture (x64, x86, arm64) | x64 |
host-arch | Host architecture used to build tool paths (empty = x64) | "" |
install-dir | Installation directory (empty = $RUNNER_TEMP/msvc-kit) | "" |
msvc-kit-version | msvc-kit binary version | latest |
components | Components: all, msvc, or sdk | all |
verify-hashes | Verify file hashes | true |
export-env | Export env vars to GITHUB_ENV | true |
The action has no vs-channel input: it always uses the newest published Visual Studio channel. Pin a channel by running the CLI directly instead of the action.
Outputs
| Output | Description |
|---|---|
msvc-version | Installed MSVC version |
sdk-version | Installed SDK version |
install-dir | Installation directory |
cl-path | Path to cl.exe |
link-path | Path to link.exe |
rc-path | Path to rc.exe |
include-path | INCLUDE env value |
lib-path | LIB env value |