Created
September 7, 2020 12:33
-
-
Save mjakeman/65c78be4532e18ed1618f313596e9a39 to your computer and use it in GitHub Desktop.
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
# MSVC Build Tools Access Script | |
# Adds VC environment variables to the currently active Powershell Shell | |
# Location of vswhere.exe (at this location since VS 2015.2) | |
$vswhere = ${env:ProgramFiles(x86)} + "\Microsoft Visual Studio\Installer\vswhere.exe" | |
# Initialises a new shell with access to the MSVC Build Tools | |
# From https://github.com/microsoft/vswhere/wiki/Find-VC | |
$path = & $vswhere -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath | |
if ($path) { | |
$path = join-path $path 'Common7\Tools\vsdevcmd.bat' | |
if (test-path $path) { | |
cmd /s /c """$path"" $args && set" | Where-Object { $_ -match '(\w+)=(.*)' } | ForEach-Object { | |
$null = new-item -force -path "Env:\$($Matches[1])" -value $Matches[2] | |
} | |
} | |
} | |
# Output Message | |
Write-Output "Initialised Build Environment" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment