了解MSI卸载 - EXECUTEACTION = INSTALL

时间:2014-11-17 15:01:03

标签: wix windows-installer wix3.5 wix3.6

我想在卸载期间运行自定义操作时出现问题。 自定义操作负责取消注册系统级Windows服务。

自定义操作:

     <CustomAction Id='UnregisterService'
    Directory='INSTALLDIR'
    ExeCommand='[INSTALLUTIL] /u &quot;/config=[INSTALLDIR]\configInstall.xml&quot;  &quot; ...
    Return='ignore'
    Execute='deferred' />

此操作在InstallExecuteSequence中安排,应在卸载和升级时调用:

    <InstallExecuteSequence>
      <Custom Action="PreventDowngrading" After="FindRelatedProducts">NEWPRODUCTFOUND</Custom>
      <RemoveExistingProducts After="InstallValidate" />
      <Custom Action='UnregisterService' After='InstallFiles'>UPGRADEFOUND OR (Installed AND NOT UPGRADINGPRODUCTCODE)</Custom>
      <Custom Action='RemAgApps' After='UnregisterService'>UPGRADEFOUND OR  (Installed AND NOT UPGRADINGPRODUCTCODE)</Custom>
...
    </InstallExecuteSequence>

问题是,当我从ARP运行卸载时,未调用uregister操作(如msi日志中所述):

Skipping action: UnregisterService (condition is false)

当我深入挖掘日志时(这很糟糕......)我发现没有“卸载”#39;动作,只安装:

Property(C): EXECUTEACTION = INSTALL
Property(C): ACTION = INSTALL
Product: BLABLA -- Installation completed successfully.MSI (c) (BC:50) [14:35:37:067]: Windows Installer installed the product. Product Name: BLABLA . Product Version: 5.1.0. Product Language: 1033. Manufacturer: BLABLA Team. Installation success or error status: 0.

我的问题是:

  1. msi卸载的流程是什么? (没有人无法在网上找到它......)
  2. 为什么我会安排&#39;安装&#39;卸载期间的操作?
  3. 如何强制卸载以运行我的&#39; unregisterService&#39;自定义动作?
  4. 谢谢!

1 个答案:

答案 0 :(得分:1)

应该避免自定义操作,直到您完全了解Windows Installer,以避免使用更脆弱的解决方案重新发明轮子。要在卸载期间删除服务,您只需要:

<ServiceControl Id="myService" Name="MyService" Stop="both" Remove="uninstall"/>

阅读这篇好文章:InstallSite: Installation Phases and In-Script Execution

Windows安装程序安装事务可以采用多种形式。初始安装,维修,维护安装,卸载,升级,补丁等。安装程序会跟踪不同级别的功能,组件和产品的状态更改,因此安装/卸载的概念更加详细。