This GitHub Action configures a complete Microsoft Visual C++ (MSVC) development environment on Windows by invoking vcvarsall.bat.
It automatically detects installed Visual Studio instances, selects the correct toolset, Windows SDK, and architecture, and exposes all environment variables required to build C and C++ projects with MSVC.
steps:
- name: Setup MSVC
uses: mlocati/setup-msvc@v1steps:
- name: Setup MSVC
uses: mlocati/setup-msvc@v1
id: msvc
with:
vs-version: latest
architecture: x64
platform-type: store
windows-sdk-version: 10.0.26100.0
toolset-version: '14.44'
spectre-mode: true
canonicalize-paths: true
if-not-windows: fail
update-env: |
!Path
debug: true
- name: Dump value of INCLUDE detected by by the setup-msvc action
run: echo "${{ steps.msvc.outputs.include }}$"- Automatic detection of installed Visual Studio versions
- Support for all MSVC architectures:
x86,x64,x86_x64,x86_arm,x86_arm64,x64_x86,x64_arm,x64_arm64 - Optional selection of:
- Windows SDK version
- MSVC toolset version
- Spectre mitigation mode
- Platform type (desktop, Store, UWP)
- Outputs all environment variables set by
vcvarsall.bat - Updates the environment for all subsequent workflow steps (by default, but it can be disabled)
- Includes a debug mode for troubleshooting
- Fully tested
Specify the Visual Studio version.
Allowed values (case insensitive):
latest(default)
Aliases:last, empty string2026
Aliases:18,18.…2022
Aliases:17,17.…2019
Aliases:16,16.…2017
Aliases:15,15.…2015
Aliases:14,14.…2013
Aliases:12,12.…2012
Aliases:11,11.…2010
Aliases:10,10.…2008
Aliases:9,9.…2005
Aliases:8,8.…
Architecture for the MSVC tools.
Allowed values (case insensitive):
x86(default in case of 32-bit OS)
Aliases:32,i386,i686,ia32,win32
Host: x86 or x64
Target: x86x64(default in case of 64-bit OS)
Aliases:64,amd64,win64,x86_64,x86-64
Host: x64
Target: x64x86_x64
Aliases:x86_amd64,x86-amd64,x86-x64
Host: x86 or x64
Target: x64x86_arm
Aliases:x86-arm,x86_arm32,x86-arm32
Host: x86 or x64
Target: ARMx86_arm64
Aliases:x86-arm64
Host: x86 or x64
Target: ARM64x64_x86
Aliases:amd64_x86,amd64-x86,x64-x86
Host: x64
Target: x86x64_arm
Aliases:amd64_arm,amd64-arm,x64-arm,amd64_arm32,amd64-arm32,x64_arm32,x64-arm32
Host: x64
Target: ARMx64_arm64
Aliases:amd64_arm64,amd64-arm64,x64-arm64
Host: x64
Target: ARM64
Configure the target application model.
Allowed values (case insensitive):
desktop(default)
For building desktop / console applicationsuwp
For building Universal Windows Platform applications (Microsoft Store apps, ...)store
Legacy alias ofuwp
Version of the Windows SDK.
The full version of the Windows SDK (eg 10.0.26100.0).
Use 8.1 to use the Windows 8.1 SDK.
Default value: use the most recent installed version.
Version of the Visual C++ compiler toolset.
It can be a major version (eg 14), a major.minor version (eg 14.44) or major.minor.patch version (eg 14.44.35207).
Default value: use the most recent installed version.
Whether spectre mode should be enabled.
Allowed values:
false(default)
for libraries without spectre mitigationstrue
for libraries with spectre mitigations
Use this input to standardize the paths in the environment variables set by Visual Studio.
Allowed values:
false(default)
Don't touch the environment variablestrue
Standardize existing paths.
For example, this may change the value ofVCINSTALLDIRfrom
C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\
to
C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC
This action only works on Windows runners.
With this option, you can control what to do when the runner is not Windows.
Allowed values (case insensitive):
fail(default)
The action will failwarn
The action will raise a warning, without failingignore
The action won't do anything
Use this option to control whether environment variables should be set for subsequent workflow steps.
Allowed values:
true(default)
The environment variables configured by Visual Studio (egPath,INCLUDE,LIB, ...) will be available in subsequent workflow stepsfalse
No environment variable will be set- newline-separated list of variable names to only update a subset of them (case insensitive)
Prepend!to a variable name to exclude it from updating.
Examples:- Set all environment variables except
PathandLIBupdate-env: | !Path !LIB
- Set only the
PathandLIBenvironment variablesupdate-env: | Path LIB
- Set all environment variables except
Use this option to control whether you want to see debug details.
Allowed values:
false(default)
No debug message will be printedtrue
Debug messages will be sent to the workflow
The path of the detected vcvarsall.bat file Visual Studio.
Example:
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvarsall.bat
The directories added by Visual Studio to the Path environment variables.
Example:
C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.44.35207\bin\HostX64\x64;C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\IDE\VC\VCPackages;…
The value of the INCLUDE environment variable set by Visual Studio.
Example:
C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.44.35207\include;C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.44.35207\ATLMFC\include;…
The value of the LIB environment variable set by Visual Studio.
Example:
C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.44.35207\ATLMFC\lib\x64;C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.44.35207\lib\x64;…
The value of the LIBPATH environment variable set by Visual Studio.
Example:
C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.44.35207\ATLMFC\lib\x64;C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.44.35207\lib\x64;…
The value of the VCINSTALLDIR environment variable set by Visual Studio.
Example:
C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\
The value of the VSINSTALLDIR environment variable set by Visual Studio.
Example:
C:\Program Files\Microsoft Visual Studio\2022\Enterprise\
The value of the VisualStudioVersion environment variable set by Visual Studio.
Example:
17.0
The value of the VCTOOLSINSTALLDIR environment variable set by Visual Studio.
Example:
C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.44.35207\
The value of the VCTOOLSVERSION environment variable set by Visual Studio.
Example:
14.44.35207
The value of the WindowsSdkDir environment variable set by Visual Studio.
Example:
C:\Program Files (x86)\Windows Kits\10\
The value of the WindowsSDKVersion environment variable set by Visual Studio.
Example:
10.0.26100.0\
The value of the WindowsSDKLibVersion environment variable set by Visual Studio.
Example:
10.0.26100.0\
The value of the UCRTVersion environment variable set by Visual Studio.
Example:
10.0.26100.0
The value of the Platform environment variable set by Visual Studio.
Example:
x64
The value of the VSCMD_ARG_HOST_ARCH environment variable set by Visual Studio.
Example:
x64
The value of the VSCMD_ARG_TGT_ARCH environment variable set by Visual Studio.
Example:
x64
All the environment variables configured by Visual Studio, in JSON format.
Please remark that Path will only include the directories added by Visual Studio.
Example:
{
"Path": "C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise\\VC\\Tools\\MSVC\\14.44.35207\\bin\\HostX64\\x64;C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise\\Common7\\IDE\\VC\\VCPackages;…"
"CommandPromptType": "Native",
"DevEnvDir": "C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise\\Common7\\IDE\\",
"Framework40Version": "v4.0",
...
}