Skip to content

Instantly share code, notes, and snippets.

@abel0b
Created May 31, 2020 10:35
Show Gist options
  • Save abel0b/d359dae2d82a0f1f53634f7e3fa69b8b to your computer and use it in GitHub Desktop.
Save abel0b/d359dae2d82a0f1f53634f7e3fa69b8b to your computer and use it in GitHub Desktop.
Use msvc in powershell script - Visual Studio 2019
$vswhere = 'C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe'
$vsfound = Test-Path $vswhere
if (-Not $vsfound) {
Write-Host "vswhere not found in $vswhere"
Exit 1
}
$vspath = & $vswhere -property installationPath
Write-Host "vspath = $vspath"
Push-Location "$vspath\Common7\Tools"
cmd /c "VsDevCmd.bat&set" | Foreach {
if ($_ -match "=") {
$v = $_.split("="); set-item -force -path "ENV:\$($v[0])" -value "$($v[1])"
}
}
Pop-Location
cl.exe hello-world.c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment