fix(copy_libcore.bat): 改进jq安装脚本的可靠性和清理逻辑
将内联的PowerShell命令改为临时脚本文件执行 添加临时文件清理逻辑确保脚本执行后不留残留
This commit is contained in:
parent
9873f670fa
commit
ad5d0c9b7a
@ -29,20 +29,28 @@ echo ⚠️ 未找到 libcore.dll
|
||||
|
||||
:install_jq
|
||||
echo 📦 安装 jq...
|
||||
powershell -Command "
|
||||
if (!(Get-Command choco -ErrorAction SilentlyContinue)) {
|
||||
Set-ExecutionPolicy Bypass -Scope Process -Force;
|
||||
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072;
|
||||
iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
|
||||
}
|
||||
choco install jq -y
|
||||
$env:Path = [System.Environment]::GetEnvironmentVariable('Path','Machine') + ';' + [System.Environment]::GetEnvironmentVariable('Path','User')
|
||||
jq --version
|
||||
"
|
||||
|
||||
:: 创建临时 PowerShell 脚本文件
|
||||
echo if (!(Get-Command choco -ErrorAction SilentlyContinue)) { > install_jq.ps1
|
||||
echo Set-ExecutionPolicy Bypass -Scope Process -Force; >> install_jq.ps1
|
||||
echo [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; >> install_jq.ps1
|
||||
echo iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1')) >> install_jq.ps1
|
||||
echo } >> install_jq.ps1
|
||||
echo choco install jq -y >> install_jq.ps1
|
||||
echo $env:Path = [System.Environment]::GetEnvironmentVariable('Path','Machine') + ';' + [System.Environment]::GetEnvironmentVariable('Path','User') >> install_jq.ps1
|
||||
echo jq --version >> install_jq.ps1
|
||||
|
||||
:: 执行 PowerShell 脚本
|
||||
powershell -NoProfile -ExecutionPolicy Bypass -File install_jq.ps1
|
||||
if %ERRORLEVEL% neq 0 (
|
||||
echo ❌ jq 安装失败
|
||||
del install_jq.ps1
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
:: 清理临时文件
|
||||
del install_jq.ps1
|
||||
|
||||
echo ✅ jq 安装成功
|
||||
|
||||
goto :verify
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user