Created
October 16, 2014 14:06
-
-
Save leafgarland/d101ded11ed485a1371e to your computer and use it in GitHub Desktop.
Powershell function to set the Visual Studio command line environment.
This file contains 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
function Set-VisualStudioEnvironment { | |
$command = "$((ls env:\VS*COMNTOOLS | sort | select -last 1).value)vsvars32.bat" | |
foreach ($line in cmd /c "`"$command`" 2>&1 && set") { | |
if ($line -match '^([^=]+)=(.*)') { | |
[System.Environment]::SetEnvironmentVariable($matches[1], $matches[2]) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This will select that latest version of VS installed. It could easily be tweaked to allow the selection of specific versions but I haven't needed that.
Set a convenient alias
Set-Alias vsvars Set-VisualStudioEnvironment
.