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:
ExeCommand='regsvr32.exe /s "[INSTALLDIR]adxloader.dll"'
ExeCommand='regsvr32.exe /s /u "[INSTALLDIR]adxloader.dll"'>
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”:
<Custom Action="RegisterAdx" After="InstallFinalize">NOT Installed</Custom>
<Custom Action="UnregisterAdx" Before="InstallInitialize">Installed</Custom>
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).
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)
- WIX Reference: http://wix.sourceforge.net/manual-wix2/wix_index.htm
- InstallExecuteSequence element reference: http://wix.sourceforge.net/manual-wix2/wix_xsd_installexecutesequence.htm
- CustomAction element reference: http://wix.sourceforge.net/manual-wix2/wix_xsd_customaction.htm
- Custom Actions wiki article: http://wix.mindcapers.com/wiki/Custom_Actions
- Windows Installer wiki article: http://en.wikipedia.org/wiki/Windows_Installer#Setup_phases
- The “ultimate” WIX tutorial: http://www.tramontana.co.hu/wix/
- Standard MSI Actions reference on MSDN: http://msdn.microsoft.com/en-us/library/aa372023(VS.85).aspx
- Problems with Tallow.exe – http://sourceforge.net/tracker/?func=detail&atid=642714&aid=1687206&group_id=105970