2

I've been using ManagedActionand and ElevatedManagedAction for sometime and everything has been great; however, I have a need now to execute actions in a particular order, or at least ensure actions are done first/last as may be necessary.

I assumed that actions were executed in the order entered for example:

 Project project =
    new Project("My Project",
        new Property("SOME_PROPERTY", "ABC"),
        new Dir(@"%ProgramFiles%\blah blah blah",
            new File(...),
            ...

        new ManagedAction(CustomActions.FirstAction, ...) {},
        ...

        new ManagedAction(CustomActions.LastAction, ...) {}
        ...

I have a number of actions and so then thought, well ... , maybe bottom up, so I put what I wanted to run first at the bottom. That didn't change the order, so then I thought maybe alphabetical and did a couple of tests and sure enough that's what it did.

So, is there another way to specify the order actions are called other than adding a prefix for the name of the action, like A01_FirstAction, A02_LastAction ...?

Thanks,

Rick

Rick
  • 119
  • 1
  • 7

1 Answers1

2

Yes there is!

project.Actions = new WixSharp.Action[] {
  new ManagedAction(CustomActions.MyFirstCustomAction,Return.check, When.Before, Step.InstallFinalize, Condition.NOT_Installed),
  new ManagedAction(CustomActions.MySecondCustomAction,Return.check, When.After, Step.PreviousAction, Condition.NOT_Installed),
  new ManagedAction(CustomActions.MyThirdCustomAction,Return.check, When.After, Step.PreviousAction, Condition.NOT_Installed)
}

Just take a look at the 2 parameters When and Step. In this case the first ManagedAction will be executed Before the step InstallFinalize. The second ManagedAction will be executed After the PreviousAction. This means after the previous action defined in the array. Same goes with the last ManagedAction. That's the way I figured out to specify an order.

Hope this helps.

NexX
  • 303
  • 3
  • 13