维克斯 元素不工作(WiX element not working)

2019-10-18 23:52发布

我运行一个WiX的软件包安装。 其中MSI软件包应该关闭,如果运行的应用程序:

<util:CloseApplication Id="CloseApplication" Target="My App.exe">1</util:CloseApplication>

这在<Product>的前元件<Feature>元素。 我加了1 ,确保条件为真。

MSI日志有这样一段话:

MSI (s) (14:94) [21:30:13:979]: Doing action: WixCloseApplications
Action ended 21:30:13: CreateFolders. Return value 1.
MSI (s) (14:68) [21:30:13:993]: Invoking remote custom action. DLL: C:\Windows\Installer\MSI5D24.tmp, Entrypoint: WixCloseApplications
MSI (s) (14!CC) [21:30:14:023]: PROPERTY CHANGE: Adding WixCloseApplicationsDeferred property. Its value is 'My App.exe2'.
Action start 21:30:13: WixCloseApplications.
MSI (s) (14!CC) [21:30:14:023]: Doing action: WixCloseApplicationsDeferred
Action start 21:30:14: WixCloseApplicationsDeferred.
Action ended 21:30:14: WixCloseApplicationsDeferred. Return value 1.
MSI (s) (14:94) [21:30:14:052]: Doing action: InstallFiles
Action ended 21:30:14: WixCloseApplications. Return value 1.
Action start 21:30:14: InstallFiles.

如果我设置的提示为“no”是这样的:

<util:CloseApplication Id="CloseApplication" Description="Closing running application" Target="My App.exe" RebootPrompt="no" ElevatedCloseMessage="no" CloseMessage="no">1</util:CloseApplication>

日志这样说:

MSI (s) (50:04) [21:43:40:214]: Doing action: WixCloseApplications
Action ended 21:43:40: CreateFolders. Return value 1.
MSI (s) (50:14) [21:43:40:238]: Invoking remote custom action. DLL: C:\Windows\Installer\MSIFFA9.tmp, Entrypoint: WixCloseApplications
Action start 21:43:40: WixCloseApplications.
MSI (s) (50:04) [21:43:40:333]: Doing action: InstallFiles
Action ended 21:43:40: WixCloseApplications. Return value 1.
Action start 21:43:40: InstallFiles.

无论哪种方式,安装完成,但原来的应用程序仍在运行,并且不会被关闭。

有问题的应用程序是一个WPF应用程序,我有<MajorUpgrade Schedule="afterInstallExecute" ...和安装使用来自WiXBA修改的管理boostrapper运行。

Answer 1:

我也无法得到CloseApplication工作,我并没有把太多的精力,但我使用了不同的方法使用的taskkill和QtExec这样可以关闭一个应用程序:

<Property Id="QtExecCmdLine" Value='"[WindowsFolder]\System32\taskkill.exe" /F /IM APP.EXE'/>
<CustomAction Id="APP.TaskClose" BinaryKey="WixCA" DllEntry="CAQuietExec" Execute="immediate" Return="ignore"/>

<InstallExecuteSequence>
  <Custom Action="APP.TaskClose" After="InstallInitialize"/>
</InstallExecuteSequence>

请注意,这是immediate CA,运行它deffered请看一看WiX的文档: http://wixtoolset.org/documentation/manual/v3/customactions/qtexec.html



文章来源: WiX element not working