Wix CustomAction与After ='InstallFinalize'在升级到下一个版本时执行了吗?

时间:2015-11-14 22:57:43

标签: wix custom-action

我使用以下代码在安装结束时启动安装程序(也提升权限):

 <Product ... >
 ...

<InstallExecuteSequence>
  <Custom Action='LaunchSetupAction' After='InstallFinalize'/>
</InstallExecuteSequence>

<!-- Workaround required for Windows7, Setup.exe can not be started directly because of UAC
http://stackoverflow.com/questions/2325459/executing-a-custom-action-that-requires-elevation-after-install -->
<Property Id="WixShellExecTarget" Value='[#SetupEXE]'/>
<CustomAction Id="LaunchSetupAction" BinaryKey="WixCA" DllEntry="WixShellExec" Execute="immediate" Return="check" Impersonate="yes"/>

...

<MajorUpgrade DowngradeErrorMessage="A later version of [ProductName] is already installed. Setup will now exit." />

</Product>

当新程序安装程序时,这很有效,但是当它从具有相同代码的先前版本升级时,安装会报告致命错误并失败。

在Windows安装程序日志中,我找到了以下内容:

 Action start 23:42:22: LaunchSetupAction.
 ...
 MSI (s) (38:88) [23:42:22:342]: Invoking remote custom action. DLL: C:\WINDOWS\Installer\MSI679.tmp, Entrypoint: WixShellExec
...
WixShellExec:  WixShellExecTarget is C:\Program Files\Me\MySetup.exe
...
WixShellExec:  Error 0x80070002: ShellExec failed with return code 2
...
WixShellExec:  Error 0x80070002: failed to launch target
...
Action ended 23:42:22: LaunchSetupAction. Return value 3.
Action ended 23:42:22: INSTALL. Return value 3.

当我在新版本的安装程序中注释掉CustomAction时,这些错误消息(找不到文件?)也很有趣。

  • 为什么要从先前版本执行的CustomAcount被卸载?

  • 有什么方法可以阻止它被运行?在升级的某个点之后,MySetup.exe不再存在,并且总是会导致致命的错误......

1 个答案:

答案 0 :(得分:0)

该自定义操作没有条件,因此将在所有类型的安装程序操作上调用它,例如卸载,添加/删除功能等。您的升级是安装新产品并卸载旧产品。

您的自定义操作需要这样的事情:

Wix: Run custom action based on condition

所以“未安装”的条件是&#39;只有在尚未安装产品时才会运行CA.

您无法解决此问题,因为该产品的卸载已嵌入系统中。您需要通过在修复自定义操作条件的情况下重建完全相同的产品来修复该旧版本的产品,然后将其修复为:

msiexec / i [新MSI的路径]重新安装=所有重新安装模式= vomus

如果您非常熟悉MSI和Orca,您可以在C:\ windows \ installer中找到缓存的MSI文件,使用Orca打开它,转到InstallExecuteSequence并将该自定义操作设置为0,然后保存。这基本上会纠正卸载顺序,以便您的升级可以正常工作。买者自负。

看来,普通卸载会给你同样的错误 - 你是否每次尝试进行卸载测试?