CMake/.gitlab/ci/vcvarsall.ps1
Ben Boeckel c1ddff67f2 ci: use JSON to transfer environment variables
The `set` command in `cmd` has terrible properties in that there's no
real structure to it. Sensitive sequences in values or variable names
that are escaping sequences can be interpreted at the wrong time or
things like newlines in values are not escaped at all and cause
ambiguities in parsing. Avoid all of that and use PowerShell to use JSON
as a communication mechanism.
2024-10-31 08:52:52 -04:00

8 lines
350 B
PowerShell

$erroractionpreference = "stop"
$all_env = cmd /c "`"$env:VCVARSALL`" $env:VCVARSPLATFORM -vcvars_ver=$env:VCVARSVERSION >NUL & powershell -Command `"Get-ChildItem env: | Select-Object -Property Key,Value | ConvertTo-Json`"" | ConvertFrom-Json
foreach ($envvar in $all_env) {
[Environment]::SetEnvironmentVariable($envvar.Key, $envvar.Value)
}