Created
May 31, 2020 10:35
-
-
Save abel0b/d359dae2d82a0f1f53634f7e3fa69b8b to your computer and use it in GitHub Desktop.
Use msvc in powershell script - Visual Studio 2019
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
$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
cf https://stackoverflow.com/questions/2124753/how-can-i-use-powershell-with-the-visual-studio-command-prompt