aboutsummaryrefslogtreecommitdiff
path: root/tools/Use-VC.ps1
blob: ad3dbcba36e788a469d90050c82e38d9c87cedef (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
function Use-VC {
    param(
        [Parameter()]
        [ValidateSet('x64', 'x86')]
        $Arch = 'x64'
    )

    if ($Arch -eq 'x86') {
        $p = 'x86';
    }
    else {
        $p = 'amd64'
    }

    cmd /c "`"$(vswhere.exe -format value -property installationPath)\VC\Auxiliary\Build\vcvars64.bat`" $p & set" |
    ForEach-Object {
        if ($_ -match '=') {
            $v = $_ -split '='
            Set-Item -Force -Path "ENV:\$($v[0])" -Value "$($v[1])"
        }
    }
    Pop-Location
    Write-Host "Visual Studio Command Prompt variables set." -ForegroundColor Yellow
}