Skip to content

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 ​

yaml
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.c

Specific Versions ​

yaml
      - name: Setup MSVC Build Tools
        uses: loonghao/msvc-kit@v1
        with:
          msvc-version: "14.44"
          sdk-version: "10.0.26100.0"
          arch: x64

Matrix Build ​

yaml
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 ​

yaml
      - 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:

yaml
      - name: Setup MSVC Build Tools
        uses: loonghao/msvc-kit@v1
        with:
          arch: x64

      - name: Build Rust project with C dependencies
        run: cargo build --release

Inputs ​

InputDescriptionDefault
msvc-versionMSVC version (empty = latest)""
sdk-versionWindows SDK version (empty = latest)""
archTarget architecture (x64, x86, arm64)x64
host-archHost architecture used to build tool paths (empty = x64)""
install-dirInstallation directory (empty = $RUNNER_TEMP/msvc-kit)""
msvc-kit-versionmsvc-kit binary versionlatest
componentsComponents: all, msvc, or sdkall
verify-hashesVerify file hashestrue
export-envExport env vars to GITHUB_ENVtrue

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 ​

OutputDescription
msvc-versionInstalled MSVC version
sdk-versionInstalled SDK version
install-dirInstallation directory
cl-pathPath to cl.exe
link-pathPath to link.exe
rc-pathPath to rc.exe
include-pathINCLUDE env value
lib-pathLIB env value

Released under the MIT License.