1 $vsInstallPath=& "C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe" -version 16.0 -property installationpath 2 Write-Output "vswhere.exe installPath: $vsInstallPath" 3 $vsInstallPath = if ("$vsInstallPath" -eq "" ) { "C:\BuildTools" } else { "$vsInstallPath" } 4 Write-Output "Final installPath: $vsInstallPath" 5 Import-Module (Join-Path $vsInstallPath "Common7\Tools\Microsoft.VisualStudio.DevShell.dll") 6 # https://en.wikipedia.org/wiki/Microsoft_Visual_C%2B%2B 7 # VS2015 14.0 8 # VS2017 14.16 9 # VS2019 14.29 10 # VS2022 14.32 11 Enter-VsDevShell -VsInstallPath $vsInstallPath -SkipAutomaticLocation -DevCmdArguments '-vcvars_ver=14.29 -arch=x64 -no_logo -host_arch=amd64' 12