From a9a1c284a513e71fb8691ad1be3fc50e45938d39 Mon Sep 17 00:00:00 2001 From: oliver Date: Tue, 13 Oct 2026 22:55:08 +0800 Subject: [PATCH] Deploy the VC++ runtime app-local for the bundled PostgreSQL. The EDB binaries link vcruntime140 (and msvcp140 via ICU), which a clean Windows install lacks, so the built-in DB and the wizard's external-DB connection test (psql) failed on fresh/offline PCs without the VC++ 2015-2022 redistributable. Copy vcruntime140(_1)/msvcp140(_1,_2) into postgres\pgsql\bin at build time and extract vcruntime140 with psql. Co-Authored-By: Claude Opus 5.5 --- packaging/build_release.ps1 | 9 +++++++++ packaging/installer/netx.iss | 3 +++ 2 files changed, 12 insertions(+) diff --git a/packaging/build_release.ps1 b/packaging/build_release.ps1 index 1390613..535f5e8 100644 --- a/packaging/build_release.ps1 +++ b/packaging/build_release.ps1 @@ -168,6 +168,15 @@ if (Test-Path (Join-Path $pgsql "bin\pg_ctl.exe")) { Remove-Item -Recurse -Force (Join-Path $pgStage "lib\pgxs") -ErrorAction SilentlyContinue Get-ChildItem (Join-Path $pgStage "share\locale") -Directory -ErrorAction SilentlyContinue | Where-Object { $_.Name -notlike "zh_CN*" } | Remove-Item -Recurse -Force + # The EDB binaries link the VC++ 2015-2022 runtime (vcruntime140, msvcp140 via ICU), which a + # clean Windows install does not have. Deploy it app-local (allowed by the VC++ redist terms) + # so the bundled PostgreSQL starts on fresh / offline machines without the redistributable. + $sys32 = Join-Path $env:SystemRoot "System32" + foreach ($dll in @("vcruntime140.dll", "vcruntime140_1.dll", "msvcp140.dll", "msvcp140_1.dll", "msvcp140_2.dll")) { + $src = Join-Path $sys32 $dll + if (-not (Test-Path -LiteralPath $src)) { throw "vc_runtime_missing_on_build_machine: $src (install the VC++ 2015-2022 x64 redistributable)" } + Copy-Item -LiteralPath $src -Destination (Join-Path $pgStage "bin\$dll") -Force + } Get-ChildItem -Path $pgsql -File -ErrorAction SilentlyContinue | ForEach-Object { Copy-Item -Path $_.FullName -Destination (Join-Path $pgStage $_.Name) -Force } diff --git a/packaging/installer/netx.iss b/packaging/installer/netx.iss index 077c32f..7691393 100644 --- a/packaging/installer/netx.iss +++ b/packaging/installer/netx.iss @@ -170,6 +170,8 @@ Source: "{#StageDir}\postgres\pgsql\bin\liblz4.dll"; Flags: dontcopy Source: "{#StageDir}\postgres\pgsql\bin\libzstd.dll"; Flags: dontcopy Source: "{#StageDir}\postgres\pgsql\bin\libxml2.dll"; Flags: dontcopy Source: "{#StageDir}\postgres\pgsql\bin\libxslt.dll"; Flags: dontcopy +; VC++ runtime deployed app-local by build_release.ps1 (clean PCs lack the redistributable). +Source: "{#StageDir}\postgres\pgsql\bin\vcruntime140.dll"; Flags: dontcopy ; These helpers are extracted for PrepareToInstall, before the new program tree is copied. Source: "{#StageDir}\packaging\_common.ps1"; Flags: dontcopy Source: "{#StageDir}\packaging\service_lifecycle.ps1"; Flags: dontcopy @@ -492,6 +494,7 @@ begin ExtractTemporaryFile('libzstd.dll'); ExtractTemporaryFile('libxml2.dll'); ExtractTemporaryFile('libxslt.dll'); + ExtractTemporaryFile('vcruntime140.dll'); Result := FileExists(ExpandConstant('{tmp}\psql.exe')) and FileExists(ExpandConstant('{tmp}\test_pg_conn.ps1')); GPgToolsReady := Result;