Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CustomAction in Wix not executing

So I'm creating my first Wix project and I seem to be having a problem executing a custom action. I'm not sure that it's being included in the msi and I'm not quite sure what I'm doing wrong. The following is my Wix file:

<?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>
    </Fragment>

    <Fragment>
      <CustomAction Id="InstallService" FileKey="ExactaDynamicManifest.exe" ExeCommand="install"/>
      <InstallExecuteSequence>
        <Custom Action="InstallService" After="InstallFinalize"/>
      </InstallExecuteSequence>
    </Fragment>
</Wix>

The last fragment contains my custom action which what I hoped would do is the following on the command line after all files have been placed in the directory:

ExactaDynamicManifest.exe install

One thing to note is that exe is actually coming from a ComponentGroupRef defined above. Not sure if this is a problem or not but thought I'd mention it. Any help would be appreciated.

like image 318
Cole W Avatar asked Jan 17 '14 19:01

Cole W


1 Answers

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>
like image 116
Cole W Avatar answered Sep 22 '22 07:09

Cole W