From 9bd2132cfa62c53b8ec902ebe9469ea57a121eb4 Mon Sep 17 00:00:00 2001 From: Jon Turney Date: Thu, 8 Nov 2018 18:38:33 +0000 Subject: azure: Rewrite importing visual studio environment variables Rewrite this in a cruder way that doesn't require installing things (and so can work with the vs2015 image) --- ci/azure-steps.yml | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'ci') diff --git a/ci/azure-steps.yml b/ci/azure-steps.yml index 6303761..4090458 100644 --- a/ci/azure-steps.yml +++ b/ci/azure-steps.yml @@ -51,14 +51,23 @@ steps: $origPath = $env:Path # import visual studio variables if ($env:compiler -eq 'msvc2015') { - $vsver = $env:compiler.Replace('msvc', '') + $vcvars = "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" } else { - $vsver = '2017' + $vcvars = "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" } - Set-PSRepository -Name PSGallery -InstallationPolicy Trusted - Install-Module Pscx -Scope CurrentUser -AllowClobber - Install-Module VSSetup -Scope CurrentUser - Import-VisualStudioVars -VisualStudioVersion $vsver -Architecture $(arch) + + ## ask cmd.exe to output the environment table after the batch file completes + $tempFile = [IO.Path]::GetTempFileName() + cmd /c " `"$vcvars`" $env:arch && 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 if ($env:compiler -eq 'clang-cl') { # drop visual studio from PATH -- cgit v1.1