0
votes

I want to have the installer/uninstaller remove a folder that contains content generated by the application at run time. I figured a Custom Action would be the way to go.

We are using WiX 3.6.

(I want it in the installer sequence for a specific reason that is not important to this question.)

Here is my CustomAction definitions in the xml:

<Binary Id="CustomActionLib" SourceFile="$(var.CustomActionLibrary.TargetDir)$(var.CustomActionLibrary.TargetName).CA.dll" />
<CustomAction Id="DeleteLocalizedCA" Impersonate="yes" BinaryKey="CustomActionLib" DllEntry="DeleteLocalized" Return="check" />
<CustomAction Id="DeleteResourcesCA" Impersonate="yes" BinaryKey="CustomActionLib" DllEntry="DeleteResources" Return="check" />

Here are my references to them:

<InstallExecuteSequence>
  <Custom Action="DeleteLocalizedCA" Before="InstallFiles"/>
  <FindRelatedProducts Before="LaunchConditions" />
  <RemoveExistingProducts After="InstallFinalize" />
  <RemoveShortcuts>Installed AND NOT UPGRADINGPRODUCTCODE</RemoveShortcuts>
</InstallExecuteSequence>

<InstallUISequence>
  <Custom Action="DeleteLocalizedCA" Before="InstallFiles"/>
  <FindRelatedProducts Before="LaunchConditions" />
</InstallUISequence>

I added the CustomActionLibrary project to the solution and added a reference to it from the installer project but it never runs, I never see it in the logs, nothing!

And thus my question, Why Don't my WiX Custom Actions Run?

1
Take a look at this first and see if it meets your needs. Writing custom actions without a thorough understanding of MSI can be dangerous. wixtoolset.org/documentation/manual/v3/xsd/util/…Christopher Painter
@ChristopherPainter - Noted, after more testing before committing the "DeleteResorucesCA" does not work and actually prevented Uninstallation, but not upgrading (due to the custom action dll not being available during a full uninstall) so it was recoverable without too much difficulty. When I revisit the installer again I'll give this a try. For now the "DeleteLocalizedCA" is doing was I wanted.K.Lawrence

1 Answers

-1
votes

After several hours of googling and reading (Blog posts, documentation, Stackoverflow, etc.) and testing I finally found a solution that none of my reading pointed to.

I had to put an InstallExecuteSequence to contain my references in a fragment that contained a ComponentGroup:

    <Fragment>
      <InstallExecuteSequence>
        <Custom Action="DeleteLocalizedCA" Before="InstallFiles">NOT Installed</Custom>
      </InstallExecuteSequence>
     <ComponentGroup Id='StringsComponents'>
       ...
     </ComponentGroup>
   </Fragment>

The Fragment that I had previously put the CustomAction reference in only had steps but no Component or ComponentGroup so apparently doesn't do anything. (I am not the original author of the installer, just taking over for a co-worker who wasn't able to help me on this).

Hopefully this helps others who are struggling with the same issue.