Correct way to init MSVC variables inside PowerShell script.
This commit is contained in:
parent
bfc8a6b35b
commit
e57d228737
43
appveyor.yml
43
appveyor.yml
|
@ -338,21 +338,27 @@ for:
|
|||
if ($env:COMPILER -eq "msvc") {
|
||||
if ($env:APPVEYOR_BUILD_WORKER_IMAGE -eq "Visual Studio 2022") {
|
||||
if ($env:ARCH -eq "x64") {
|
||||
& "C:\Program Files (x86)\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvars64.bat"
|
||||
cmd.exe /c "call `"C:\Program Files (x86)\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvars64.bat`" && set > %temp%\vcvars.txt"
|
||||
} elseif ($env:ARCH -eq "arm64") {
|
||||
& "C:\Program Files (x86)\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvarsamd64_arm64.bat"
|
||||
cmd.exe /c "call `"C:\Program Files (x86)\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvarsamd64_arm64.bat`" && set > %temp%\vcvars.txt"
|
||||
} else {
|
||||
& "C:\Program Files (x86)\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvars32.bat"
|
||||
cmd.exe /c "call `"C:\Program Files (x86)\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvars32.bat`" && set > %temp%\vcvars.txt"
|
||||
}
|
||||
} elseif ($env:APPVEYOR_BUILD_WORKER_IMAGE -eq "Visual Studio 2019") {
|
||||
if ($env:ARCH -eq "x64") {
|
||||
& "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars64.bat"
|
||||
cmd.exe /c "call `"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars64.bat`" && set > %temp%\vcvars.txt"
|
||||
} elseif ($env:ARCH -eq "arm64") {
|
||||
& "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvarsamd64_arm64.bat"
|
||||
cmd.exe /c "call `"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvarsamd64_arm64.bat`" && set > %temp%\vcvars.txt"
|
||||
} else {
|
||||
& "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars32.bat"
|
||||
cmd.exe /c "call `"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars32.bat`" && set > %temp%\vcvars.txt"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Get-Content "$env:temp\vcvars.txt" | Foreach-Object {
|
||||
if ($_ -match "^(.*?)=(.*)$") {
|
||||
Set-Content "env:\$($matches[1])" $matches[2]
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if ($env:MSYS2_PACKAGES -eq "true") {
|
||||
& 'C:\msys64\usr\bin\bash' -lc "pacman --noconfirm -Syuu"
|
||||
|
@ -452,28 +458,33 @@ for:
|
|||
if ($env:COMPILER -eq "msvc") {
|
||||
if ($env:APPVEYOR_BUILD_WORKER_IMAGE -eq "Visual Studio 2022") {
|
||||
if ($env:ARCH -eq "x64") {
|
||||
& "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvars64.bat"
|
||||
cmd.exe /c "call `"C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvars64.bat`" && set > %temp%\vcvars.txt"
|
||||
} else {
|
||||
& "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvars32.bat"
|
||||
cmd.exe /c "call `"C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvars32.bat`" && set > %temp%\vcvars.txt"
|
||||
}
|
||||
} elseif ($env:APPVEYOR_BUILD_WORKER_IMAGE -eq "Visual Studio 2019") {
|
||||
if ($env:ARCH -eq "x64") {
|
||||
& "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars64.bat"
|
||||
cmd.exe /c "call `"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars64.bat`" && set > %temp%\vcvars.txt"
|
||||
} else {
|
||||
& "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars32.bat"
|
||||
cmd.exe /c "call `"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars32.bat`" && set > %temp%\vcvars.txt"
|
||||
}
|
||||
} elseif ($env:APPVEYOR_BUILD_WORKER_IMAGE -eq "Visual Studio 2017") {
|
||||
if ($env:ARCH -eq "x64") {
|
||||
& "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvars64.bat"
|
||||
cmd.exe /c "call `"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvars64.bat`" && set > %temp%\vcvars.txt"
|
||||
} else {
|
||||
& "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvars32.bat"
|
||||
cmd.exe /c "call `"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvars32.bat`" && set > %temp%\vcvars.txt"
|
||||
}
|
||||
} elseif ($env:APPVEYOR_BUILD_WORKER_IMAGE -eq "Visual Studio 2015") {
|
||||
if ($env:ARCH -eq "x64") {
|
||||
& "C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\SetEnv.cmd" /x64
|
||||
& "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x86_amd64
|
||||
cmd.exe /c "call `"C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\SetEnv.cmd`" /x64 && call `"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat`" x86_amd64 && set > %temp%\vcvars.txt"
|
||||
} else {
|
||||
& "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x86
|
||||
cmd.exe /c "call `"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvars64.bat`" && set > %temp%\vcvars.txt"
|
||||
}
|
||||
}
|
||||
|
||||
Get-Content "$env:temp\vcvars.txt" | Foreach-Object {
|
||||
if ($_ -match "^(.*?)=(.*)$") {
|
||||
Set-Content "env:\$($matches[1])" $matches[2]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user