Thursday, January 31, 2008

WiX Toolkit (Windows Installer) Custom actions and conditions

Normally, for setup projects I use InnoSetup from Jordan Russel which is, put simple, the best setup creator you will find.

However, for a project I was forced to produce a Windows Installer package and used the WiX toolkit for it. Basically, after several dead-ends I was finally completely stuck. I simply wanted to have Windows Installer executing a custom action on every install of the application, regardless if it's already installed or not. If the application is being removed, my custom action shouldn't be executed.

By default, you would simply use the condition "NOT Installed" which means: If the application is not installed, execute it. Else, leave it alone. But as I said I wanted it to be execute every time somebody issues a command like MSIEXEX /I MyProduct.msi. The default condition would evaluate to FALSE (since the application is already installed) and thus, the custom action isn't started. Of course, you could pass /fa to MSIEXEC.exe but I feared this would be forgotten and thus I would get more "Nothing is working here calls".

After searching and testing for nearly two hours (and found an excellent post about custom actions and properties from Jeff Wharton) I was able to find the correct solution:

<custom action="LaunchExe" after="InstallInitialize">NOT (REMOVE="ALL")</custom>

This simply means: If the application is NOT being removed, execute the custom action.

If you know how, it's simple.

1 comment:

  1. Why couldn't you just say "NOT REMOVE"? -- I think 'REMOVE="ALL"' might only be true if the user is removing everything...

    ReplyDelete