Skip to content

Instantly share code, notes, and snippets.

@fnichol
Created November 10, 2020 08:35
Show Gist options
  • Save fnichol/c0f017b404d2be165619f2349fe18d47 to your computer and use it in GitHub Desktop.
Save fnichol/c0f017b404d2be165619f2349fe18d47 to your computer and use it in GitHub Desktop.
PowerShell Profile loading Visual Studio 2019
# Thanks to: https://gist.github.com/justinian/81a2e55c89e8301a8a96
$tempFile = [IO.Path]::GetTempFileName()
## Store the output of cmd.exe. We also ask cmd.exe to output
## the environment table after the batch file completes
cmd /c " `"C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Auxiliary\Build\vcvars64.bat`" && set > `"$tempFile`" "
## Go through the environment variables in the temp file.
## For each of them, set the variable in our local environment.
Get-Content $tempFile | Foreach-Object {
if($_ -match "^(.*?)=(.*)$")
{
Set-Content "env:\$($matches[1])" $matches[2]
}
}
Remove-Item $tempFile
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment