Rupert Puxton
Rupert Puxton

Reputation: 53

WiX Custom action not executing

I am having trouble with a Wix custom action not executing. The installer continually rolls itself back even when the custom action returns ActionResult.Success.

Custom Action (C#)

[CustomAction]
public static ActionResult SetPermissionsToAppDataFolder(Session session)
{
    return ActionResult.Success;
}

Custom Action Definition in Wix

<!-- Custom Action -->
<Binary Id="CustomActionLibrary" SourceFile="$(var.CustomActionFolder)InstallerCustomActions.CA.dll" />
<CustomAction Id="CustomActionInstallDirectoryPermission"
              BinaryKey="CustomActionLibrary"
              DllEntry="SetPermissionsToAppDataFolder"
              Execute="deferred"
              Return="check" />

Install sequence calling the custom action

<!-- Install Sequences -->
<InstallExecuteSequence>
        <Custom Action="CustomActionInstallDirectoryPermission" Before="InstallFinalize">NOT Installed</Custom>
</InstallExecuteSequence>

The installer compiles fine so there is no problem finding the custom action library file. The issue is that the installer gets to the final stage of installation before rolling back. When we remove the call to the custom action in the install sequence the installer completes.

From my understanding the custom action CA.dll gets embedded into the final installer. Initially I'd thought the CA.dll needed to be distributed alongside the installer but later discovered the installer compiles it into the final .msi.

I have "wired" the custom action library using the code found at: http://www.codeproject.com/Articles/132918/Creating-Custom-Action-for-WIX-Written-in-Managed

No matter what I do I cannot get the installer to complete, even when the custom action returns "success". Any help is appreciated.

Upvotes: 3

Views: 3418

Answers (1)

Francis
Francis

Reputation: 1904

For anyone struggling with WiX and who stumbled here.

A few suggestions :

1) Have you tried adding Debugger.Launch() to the first line of your CustomAction code (i.e. above the Return ActionResult.Success; )? If you don't get a dialog box asking to launch a debugger, then you know your WiX script is not referring to your CA.dll correctly or there's a problem with its invocation.

2) If you are using Fragments and the CustomAction elements sit inside them, try taking them out and put them under the Product element instead.

3) If you're going to use deferred execution, have you tried Impersonate="no" attribute in your CustomAction

Upvotes: 2

Related Questions