OpenConsole.psm1: use DevShell module; tidy up for PowerShell 6+ (#9508)

Saw this while snooping around, the gci command on PowerShell core seems
to store the full path in the variable as oppose to just the leaf.

The other modification is to use the PowerShell module that vs ships to
setup the environment.
This commit is contained in:
Luan Vitor Simião Oliveira
2021-03-16 14:29:38 -03:00
committed by GitHub
parent 44f1ba6d4d
commit c5124956a9

View File

@@ -41,7 +41,7 @@ function Import-LocalModule
Write-Verbose "$Name already downloaded"
$versions = Get-ChildItem "$modules_root\$Name" | Sort-Object
Get-ChildItem -Path "$modules_root\$Name\$($versions[0])\$Name.psd1" | Import-Module
Get-ChildItem -Path "$($versions[0].FullName)\$Name.psd1" | Import-Module
}
}
@@ -74,16 +74,15 @@ function Set-MsbuildDevEnvironment
default { throw "Unknown architecture: $switch" }
}
$vcvarsall = "$vspath\VC\Auxiliary\Build\vcvarsall.bat"
$devShellModule = "$vspath\Common7\Tools\Microsoft.VisualStudio.DevShell.dll"
Import-Module -Global -Name $devShellModule
Write-Verbose 'Setting up environment variables'
cmd /c ("`"$vcvarsall`" $arch & set") | ForEach-Object {
if ($_ -match '=')
{
$s = $_.Split("=");
Set-Item -force -path "env:\$($s[0])" -value "$($s[1])"
}
}
Enter-VsDevShell -VsInstallPath $vspath -SkipAutomaticLocation `
-devCmdArguments "-arch=$arch" | Out-Null
Set-Item -Force -path "Env:\Platform" -Value $arch
Write-Host "Dev environment variables set" -ForegroundColor Green
}