CustomAction in Wix not executing

陌路散爱 提交于 2019-12-04 07:26:18
Cole W

I finally got something that is working. My initial problem of the CustomAction not loading seemed to be due to it being in a different <fragment>. I consolidated all of the code into a single fragment and it seemed to run.

After battling with user permissions etc I finally ended up with this solution:

<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
    <Product Id="*" Name="ExactaDynamicManifest" Language="1033" Version="1.0.0.0" Manufacturer="Bastian Software Solutions" UpgradeCode="274ff2d9-e291-4706-a8db-ce80ccd91538">
      <Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine"/>

      <MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
      <MediaTemplate />

      <Feature Id="ProductFeature" Title="ExactaDynamicManifest" Level="1">
        <ComponentGroupRef Id="ExactaDynamicManifest"/>
      </Feature>

      <Icon Id="exacta.ico" SourceFile="icons\exacta.ico"/>
      <Property Id="ARPPRODUCTICON" Value="exacta.ico" />

    </Product>

    <Fragment>
      <Directory Id="TARGETDIR" Name="SourceDir">
        <Directory Id="ProgramFilesFolder">
          <Directory Id="ExactaFolder" Name ="Exacta">
            <Directory Id="INSTALLFOLDER" Name="ExactaExactaDynamicManifest" />
          </Directory>
        </Directory>
      </Directory>

      <CustomAction Id="RunTopShelfServiceInstall" Directory="INSTALLFOLDER" Execute="deferred" Return="ignore" Impersonate="no" ExeCommand="[INSTALLFOLDER]ExactaDynamicManifest.exe install"/>
      <CustomAction Id="RunTopShelfServiceUninstall" Directory="INSTALLFOLDER" Execute="deferred" Return="ignore" Impersonate="no" ExeCommand="[INSTALLFOLDER]ExactaDynamicManifest.exe uninstall"/>

      <InstallExecuteSequence>
        <Custom Action="RunTopShelfServiceInstall" After="InstallFiles">
          NOT Installed
        </Custom>
        <Custom Action="RunTopShelfServiceUninstall" After='InstallInitialize'>
          (NOT UPGRADINGPRODUCTCODE) AND (REMOVE="ALL")
        </Custom>
      </InstallExecuteSequence>

    </Fragment>
</Wix>
  1. Are you going to register a service using a custom action? You also have to handle uninstall, repair actions. It's much simpler to use standard MSI feature to install services: http://wixtoolset.org/documentation/manual/v3/xsd/wix/serviceinstall.html

  2. If you want to use custom actions for this purpose and UAC is enabled your service won't be installed due to permissions. You have to use deferred and not impersonated custom action scheduled before InstallFinalize (after InstallFinalize custom actions can't be scheduled).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!