-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathRunVsDevCmd.ps1
More file actions
18 lines (16 loc) · 842 Bytes
/
RunVsDevCmd.ps1
File metadata and controls
18 lines (16 loc) · 842 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
$ProgramFiles86 = (${env:ProgramFiles(x86)}, ${env:ProgramFiles} -ne $null)[0]
$vswhere = "${ProgramFiles86}\Microsoft Visual Studio\Installer\vswhere.exe"
if (-NOT (Test-Path $vswhere)) {
Write-Host "Could not find vswhere.exe in $Env:ProgramFiles(x86)\Microsoft Visual Studio\Installer"
exit
}
$installationPath = Invoke-Expression "& '$vswhere' -prerelease -latest -property installationPath"
Write-Host "installationPath = ${installationPath}"
if ($installationPath -and (Test-Path "$installationPath\Common7\Tools\VSDevCmd.bat")) {
& "${env:COMSPEC}" /s /c "`"$installationPath\Common7\Tools\VSDevCmd.bat`" -no_logo && set" | foreach-object {
$name, $value = $_ -split '=', 2
Write-Host "Setting $name to $value"
[Environment]::SetEnvironmentVariable($name, $value, "User")
# Set-Content env:\"$name" $value
}
}