Created
May 22, 2024 01:51
-
-
Save brcha/def9f762f823ce6be465439f055819b1 to your computer and use it in GitHub Desktop.
vcvars.ps1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Allow executing CMD scripts | |
function Invoke-CmdScript { | |
param( | |
[String] $scriptName | |
) | |
$cmdLine = """$scriptName"" $args & set" | |
& $Env:SystemRoot\system32\cmd.exe /c $cmdLine | | |
select-string '^([^=]*)=(.*)$' | foreach-object { | |
$varName = $_.Matches[0].Groups[1].Value | |
$varValue = $_.Matches[0].Groups[2].Value | |
set-item Env:$varName $varValue | |
} | |
} | |
# Generic function that set Visual Studio variables to newest versions | |
function VcVarsAll { | |
param( | |
[String] $arch = "x64", | |
[String] $sdk = "10.0.22000.0", | |
[String] $vcvars = "14.31" | |
) | |
Invoke-CmdScript 'C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvarsall.bat' $arch $sdk "-vcvars_ver=$vcvars" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment