Update for this post: I haven't checked it out yet, but from what I gather, with WIX 3.0 new heat tool, the bug (see related links below) that forced us to come up with this solution will be gone :) Also, please take note, that the solution described is not the standard way for registering a Com Server in an MSI installation.
Last night I had to deal with this issue, in one of the projects I’m involved in. So, after sifting through some forums, msdn and wix schema reference here is the end result. Its a fairly simple thing… in retrospect! :)
Adding the custom actions:
<CustomAction Id="RegisterAdx"
Directory="INSTALLDIR"
ExeCommand='regsvr32.exe /s "[INSTALLDIR]adxloader.dll"'
Return="check">
</CustomAction>
<CustomAction Id="UnregisterAdx"
Directory="INSTALLDIR"
ExeCommand='regsvr32.exe /s /u "[INSTALLDIR]adxloader.dll"'>
</CustomAction>
For those of you who don’t recognize this dll, its a required library by Add-in Express, we are using it to ease our development of GhotIt plug-in(s) for Microsoft Office applications.
So, we have two simple custom actions, the first, silently registers the dll from the installation directory and the second (silently), unregister it. The first action (RegisterAdx) is also set to fail the installation if not successful, by adding the Return=”check” attribute.
Please note that in both actions the ExeCommand attribute value is decorated with an Apostrophe (‘) instead of a Quotation Mark (“). This allows us to easily decorate the file statement [INSTALLDIR]adxloader.dll inside the value’s string with quotation marks, since the install directory might include whitespaces in it.
Next, we have to tell the MSI Installer when to execute these actions, Ideally this will happen after the installation finishes copying the files and before the files are deleted during the uninstall process.
Defining the execution “sequence”:
<InstallExecuteSequence>
<Custom Action="RegisterAdx" After="InstallFinalize">NOT Installed</Custom>
<Custom Action="UnregisterAdx" Before="InstallInitialize">Installed</Custom>
</InstallExecuteSequence>
First, although these actions are defined in a “sequence”, there is no real sequence here. Action RegisterAdx will only execute after the installation is finalized and only if the product isn’t installed (NOT Installed) while action UnregisterAdx will only execute before the installation is initialized and only if the product is already installed (Installed).
Epilogue:
In my installation project, these XML elements were placed directly under the <Product> element, but different scenarios might require them to be placed elsewhere.
This is a very simple solution to a simple problem, and as such it makes a few assumptions I should point out:
- The target computer has the regsvr32.exe on it.
- Regsvr32.exe is included in the computer’s environment path (this one is not so naive… if its there its probably in the path)
- There is no previous installation present. (or the previous installation will not be recognized, causing the NOT Installed condition to fail)
Related links: