Created
December 13, 2016 13:52
-
-
Save bpatra/d10ecab36f75f46ae62913051380899e to your computer and use it in GitHub Desktop.
Powershell functions to load VS2015 VCVARS in Powershell (you may want to add it to you powsershell profile)
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 Invoke-BatchFile | |
{ | |
param([string]$Path, [string]$Parameters) | |
$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.exe /c " `"$Path`" $Parameters && 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 | |
} | |
function Import-VS2015Vars | |
{ | |
Invoke-BatchFile "${env:VS140COMNTOOLS}vsvars32.bat" $vcargs | |
#VCVARS invoke in VS2012 are silent... | |
Write-Host "VS2015 vcvars loaded..." | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment