Last active
July 30, 2023 18:54
-
-
Save Ed94/7d82734dafcf6d9e1b33501f78b64482 to your computer and use it in GitHub Desktop.
Find and load the msvc developer powershell from the default installation paths
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
$ErrorActionPreference = "Stop" | |
# Use vswhere to find the latest Visual Studio installation | |
$vswhere_out = & "C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe" -latest -property installationPath | |
if ($null -eq $vswhere_out) { | |
Write-Host "ERROR: Visual Studio installation not found" | |
exit 1 | |
} | |
# Find Launch-VsDevShell.ps1 in the Visual Studio installation | |
$vs_path = $vswhere_out | |
$vs_devshell = Join-Path $vs_path "\Common7\Tools\Launch-VsDevShell.ps1" | |
if ( -not (Test-Path $vs_devshell) ) { | |
Write-Host "ERROR: Launch-VsDevShell.ps1 not found in Visual Studio installation" | |
Write-Host Tested path: $vs_devshell | |
exit 1 | |
} | |
# Launch the Visual Studio Developer Shell | |
Push-Location | |
& $vs_devshell @args | |
Pop-Location |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment