Search code examples
c#wixwindows-installercustom-action

Managed(C#) custom action in WIX doesn't work (error code 1154)


I'm developing a Custom Action to install the same file into multiple folders(that are determined at runtime).

The custom action resides inside a Wix C# Custom Action Project. It's code looks like this:

public class CustomActions
{
    [CustomAction]
    public static ActionResult InstallToTrunks(Session session)
    {
        // some logic
    }
}

The relevant WIX markup looks like this:

    <Binary Id='CustomActions' SourceFile='..\CustomActions\bin\$(var.Configuration)\CustomActions.dll' />
<CustomAction Id='InstallToTrunks' BinaryKey='CustomActions' DllEntry='InstallToTrunks' Execute='deferred' Return='check'/>

<InstallExecuteSequence>
  <Custom Action='InstallToTrunks' After='InstallInitialize'></Custom>
</InstallExecuteSequence>

However, when I try to run the setup, it fails, and log says: CustomAction InstallToTrunks returned actual error code 1154 (note this may not be 100% accurate if translation happened inside sandbox)

Any help would be very welcome. Alternatively, if you have a suggestion on how to achieve what I'm trying to do(install same file into multiple folders that can be determined only at retuntime) without CustomActions, that would be helpful too.

Thanks.


Solution

  • It looks like you're referencing the custom action assembly, rather than the custom action DLL. Those custom action projects produce an unmanaged custom action DLL called xxxx.CA.dll which contains a compressed copy of your custom action assembly and its dependencies.

    Try:

    <Binary Id='CustomActions' SourceFile='..\CustomActions\bin\$(var.Configuration)\CustomActions.CA.dll' />