如何在Wix Bundle中配置ExePackage调用独立卸载程序
Wix Bundle ExePackage 卸载路径配置问题解决
问题出在你当前的配置中,Wix 默认会将 UninstallCommand 的内容作为参数传递给缓存的安装程序(也就是 C:\ProgramData\Package Cache 里的 test.exe),而不是直接执行你指定的卸载程序。这就导致日志里出现了错误的执行命令,最终触发了重复安装而非卸载。
正确配置方案
你需要添加 InstallerType="custom" 属性,明确告诉 Wix 这是一个自定义安装程序,UninstallCommand 是需要独立执行的完整命令,而非安装程序的参数。同时确保路径变量解析正确,修改后的配置如下:
<ExePackage Id="exe" DisplayName="name" Name="path\test.exe" SourceFile="path\test.exe" Compressed="no" PerMachine="yes" Permanent="yes" Vital="yes" InstallCondition="EXEPRESENT=0" InstallCommand="-y" DetectCondition="EXEPRESENT=1" InstallerType="custom" UninstallCommand="[ProgramFiles64Folder]path\Uninstall\setup.exe -uninstall"/>
关键说明
InstallerType="custom":这是核心修改,让 Wix 不再将UninstallCommand作为参数传给缓存的安装程序,而是直接执行该命令。- 注意路径中的斜杠:配置里的
[ProgramFiles64Folder]本身已经包含了末尾的反斜杠,所以后面直接跟path即可,避免出现双斜杠(\\)。
修改后,卸载时的日志应该会显示直接执行 C:\Program Files\path\Uninstall\setup.exe -uninstall,而不是调用缓存的 test.exe,这样就能正确触发卸载流程。
内容的提问来源于stack exchange,提问作者Sumana
相关产品推荐
相关产品推荐

