Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions scripts/vs-shell.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,17 @@ if($env:VSINSTALLDIR -eq $null) {
}
}

# Enter-VsDevShell parses cmd.exe `set` output line by line, so a multi-line
# value (e.g. BUILDKITE_MESSAGE) leaks each `KEY=VALUE`-shaped body line as a
# real env var. Stash multi-line vars around the loader to keep them intact.
$multilineEnv = @{}
foreach ($item in (Get-ChildItem env:)) {
if ($item.Value -match "[\r\n]") {
$multilineEnv[$item.Name] = $item.Value
Remove-Item -LiteralPath "env:$($item.Name)"
}
}

Push-Location $vsDir
try {
$vsShell = (Join-Path -Path $vsDir -ChildPath "Common7\Tools\Launch-VsDevShell.ps1")
Expand All @@ -47,6 +58,9 @@ if($env:VSINSTALLDIR -eq $null) {
}
} finally {
Pop-Location
foreach ($name in $multilineEnv.Keys) {
Set-Item -LiteralPath "env:$name" -Value $multilineEnv[$name]
}
}
}

Expand Down
Loading