Wix Bundle中PostgreSQL安装前置条件配置无效,求问题排查
Wix Bundle PostgreSQL前置条件检测失效排查方案
以下是导致你的PostgreSQL前置条件检测失效的几个常见原因及修复方案:
1. 注册表搜索的架构重定向问题
你检测的是x64版本的PostgreSQL,但Wix Bundle默认以32位模式运行,会自动将HKLM\SOFTWARE的搜索重定向到HKLM\SOFTWARE\Wow6432Node,而x64的PostgreSQL注册表项实际在原生的HKLM\SOFTWARE路径下。
修复方法:在RegistrySearch中添加Win64="yes"属性,强制使用64位注册表视图:
<RegistrySearch Id="POSTGRESINSTALLED_SEARCH" Key="SOFTWARE\PostgreSQL\Installations\postgresql-x64-14" Root="HKLM" Type="raw" Name="Branding" Win64="yes" />
2. Bundle中变量定义错误
Wix Bundle的变量体系和MSI不同,你使用的<Property>是MSI专属元素,在Bundle上下文中无法正确传递注册表搜索结果。Bundle需要用<Variable>来存储搜索值。
修复方法:将Fragment中的<Property>替换为<Variable>:
<Fragment> <Variable Id="POSTGRESINSTALLED" Type="string" Value=""> <RegistrySearch Id="POSTGRESINSTALLED_SEARCH" Key="SOFTWARE\PostgreSQL\Installations\postgresql-x64-14" Root="HKLM" Type="raw" Name="Branding" Win64="yes" /> </Variable> </Fragment>
3. 注册表路径准确性问题
PostgreSQL的注册表项名称可能因安装选项不同而变化,比如用户自定义了安装名称,或者版本号格式有差异(是否带补丁号等)。
验证方法:
- 打开注册表编辑器(regedit)
- 导航到
HKLM\SOFTWARE\PostgreSQL\Installations - 确认实际存在的子项名称是否和你配置的
postgresql-x64-14完全一致
如果不一致,修改RegistrySearch中的Key路径为实际存在的项。
4. 安装条件逻辑验证
你当前的InstallCondition="NOT POSTGRESINSTALLED"逻辑是正确的(当变量有值时跳过安装),但需要确保变量能被正确赋值。
修改后的完整配置示例
<?xml version="1.0" encoding="UTF-8"?> <Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"> <Bundle Name="Title" Version="1.0.0.0" Manufacturer="Manufacture" UpgradeCode="5aee5af2-10c7-42d1-bde6-c7dadf736786"> <BootstrapperApplicationRef Id="WixStandardBootstrapperApplication.RtfLicense"/> <?define InstallPgCommand=--unattendedmodeui minimal --mode unattended --superpassword "super_pwd" --servicename "service_name" --servicepassword "service_pwd" --serverport 5433?> <Chain> <!-- Install postgres --> <ExePackage SourceFile="ThirdPartyApps\postgresql-14.3-1-windows-x64.exe" Compressed ="yes" Vital ="yes" Permanent ="yes" InstallCommand="$(var.InstallPgCommand)" InstallCondition="NOT POSTGRESINSTALLED" /> </Chain> </Bundle> <Fragment> <Variable Id="POSTGRESINSTALLED" Type="string" Value=""> <RegistrySearch Id="POSTGRESINSTALLED_SEARCH" Key="SOFTWARE\PostgreSQL\Installations\postgresql-x64-14" Root="HKLM" Type="raw" Name="Branding" Win64="yes" /> </Variable> </Fragment> </Wix>
内容的提问来源于stack exchange,提问作者Hasagiii
相关产品推荐
相关产品推荐

