Jon H
Jon H

Reputation: 1071

Executing arbitrary C# code in WiX

I want to run some arbitrary code in a WiX installer and have the results of that available as early on as is possible.

To test this, I am using the return value to set a label field. It doesn't seem to work. I can get it to run when I put a

<Publish Event="DoAction" Value="CustomAction1">1</Publish>

inside the control for a next button, but this is too 'late'. I want that code executed right at the start.

Here is what I tried:

<Binary Id="WixCustomActions" SourceFile="$(var.SolutionDir)$(var.CAProjectName)\bin\Release\$(var.CAProjectName).CA.dll" />

<CustomAction Id="CustomAction1" BinaryKey="WixCustomActions" DllEntry="CustomAction1" Execute="deferred" Return="asyncWait"/> (tried many combinations here)`

Later on.....

<InstallExecuteSequence>
    <Custom Action="CustomAction1" After="InstallInitialize">1</Custom>
</InstallExecuteSequence>

on paper this should work.

I know it isn't a problem with the custom action itself, because when placed on the next key, I get the desired result.

What is the solution?

Upvotes: 1

Views: 2030

Answers (2)

uzrgm
uzrgm

Reputation: 395

<InstallUISequence>
  <Custom Action="Your_Custom_Action"
          After="CostFinalize"
          Overridable="yes">NOT Installed</Custom>
</InstallUISequence>

This code launches 'Your_Custom_Action' at the very begining of the installation.

Upvotes: 0

hungryMind
hungryMind

Reputation: 7009

The InstallExecuteSequence table lists actions that are executed when the top-level INSTALL action is executed. Try using LaunchConditions on InstallUISequence

Upvotes: 1

Related Questions