I've implemented my first MSI-Installer with WIX-Toolset 3.6
which includes Custom Actions for Backup
, Installation
and Rollback
.
The Backup and Installation works fine, but I have a problem with my Rollback Custom Action. I have defined my Custom Actions like this:
<!-- Custom actions -->
<CustomAction Id="CA_Install" Return="check" BinaryKey="BIN_CaLibrary" Execute="deferred" DllEntry="CaInstall" />
<CustomAction Id="CA_Rollback" Return="check" BinaryKey="BIN_CaLibrary" Execute="rollback" DllEntry="CaRollback" />
<CustomAction Id="CA_Backup" Return="check" BinaryKey="BIN_CaLibrary" Execute="immediate" DllEntry="CaBackup" />
<CustomAction Id="CA_SetTargetDir" Return="check" BinaryKey="BIN_CaLibrary" Execute="immediate" DllEntry="CaSetTargetDir" />
<CustomAction Id="CA_SetTargetDirAndInstallTypeForInstall" Return="check" Property="CA_Install" Value="InstallType=[INSTALLTYPE];TargetDir=[TARGETDIR]" />
<CustomAction Id="CA_SetTargetDirForRollback" Return="check" Property="CA_Rollback" Value="TargetDir=[TARGETDIR]" />
<!-- Linking custom actions to the install sequence -->
<InstallExecuteSequence>
<Custom Action="CA_SetTargetDir" Before="AppSearch" />
<Custom Action="CA_Backup" After="CA_SetTargetDir" />
<Custom Action="CA_SetTargetDirForRollback" Before="CA_Rollback" />
<Custom Action="CA_SetTargetDirAndInstallTypeForInstall" Before="CA_Install"/>
<Custom Action="CA_Rollback" Before="CA_Install"/>
<Custom Action="CA_Install" Before="InstallFinalize" />
</InstallExecuteSequence>
In my CA_Backup
I always create a Backup-Directory with the old version of the application (even if the installation is successful). When my CA_Install
runs into an exception the Installer jumps to my own Rollback Custom Action CA_Rollback
. In this Custom Action I delete all files in TARGETDIR
and reproduce the files from Backup-Directory. It does exactly what it should do but after the CA_Rollback
the Wix-Installer automatically rollback the other Custom Actions like InstallFiles
. And so it deletes all the files that are reproduced from the Backup-Directory in my CA_Rollback
before.
Is it possible to disable the automatic rollback of the InstallFiles
Custom Action? Or is there an other solution for my problem?
It's also strange that the ProgressText of the CA_Rollback is not what I've defined, but the standard text of WiX-Framework.
<ProgressText Action="CA_SetTargetDir">Getting Installation-Type...</ProgressText>
<ProgressText Action="CA_Backup">Creating Backup-Directory...</ProgressText>
<ProgressText Action="CA_Install">Updating Application...</ProgressText>
<ProgressText Action="CA_Rollback">Rollback the Application...</ProgressText>
So, when the Installer jumps to the CA_Rollback the ProgressText is NOT "Rollback the Application..." but in the other Custom Actions (CA_SetTargetDir, CA_Backup, CA_Install) the ProgressText is shown as defined.
EDIT:
I've found the DisableRollback Action and I'd like to used it like this in my InstallExecuteSequence
:
<DisableRollback After="CA_Rollback" />
So I'd like to run my own Rollback CA_Rollback
, but want to disable the automatic rollback of the other Custom Actions. But when I include this, there is no Rollback at all.
Your question is a bit unclear to me - I am quite confused as to what you are really asking, and why you have implemented rollback this way. However, here is a general answer:
Rollback support is a built-in feature of Windows Installer and you don't need to implement this feature at all. What you might need is a rollback custom action to complement a custom action that makes changes to the target system. See info below.
Files replaced during the installation of your software, as well as registry keys, ini file settings, and other settings properly defined in the MSI tables, are all stored in a hidden folder directly on the system drive (generally C:\Config.MSI) during installation. The files have extensions .RBS and .RBF - Rollback Script Files - that restore the system to the previous state should an error occur during installation, barring any changes done in custom actions.
Custom actions are special in the sense that they are by definition non-standard, and hence there is no built-in support for their rollback. In order to roll back changes for these, you need to write a complimentary rollback custom action to undo what the original custom action did. This can be highly complex, and requires careful scheduling, implementation and testing. Note that a read-only custom action that performs checking, property retrieval or other tasks without making any system changes does not require rollback. Use of these non-invasive custom actions can be very effective. I am particularly fond of using these custom actions to gather many operations in one script for easier inspection by other setup developers. MSI's runtime behavior is like a complex watch - many interactions and timing issues are possible and this makes it difficult to get a quick overview. Changes may be required in 2-3 different, seemingly unrelated places to get the behavior you need. Scripts are sequential and can be commented for easier comprehension and crucially changed at a single location. For team work I find these scripts essential.
It is crucial to point out that custom actions tend to be unnecessary since the same feature has been implemented already in much more reliable ways using built-in Windows Installer features, or WIX features. Wix is an XML based toolkit allowing the compilation of MSI files from XML source files. The toolkit is written by Rob Mensching - a member of the Windows Installer team from Microsoft at one point - and is highly reliable, highly customizable, and full of advanced and simple features alike.
The importance of avoiding unnecessary custom actions if at all possible, can not be overstated. Check whether Windows Installer or Wix has support for it.
MSI features full support for handling merging of ini file settings, fonts, environment variables, registry keys, COM information, shortcuts, file extensions, launch conditions, GAC installation, ODBC, etc...
WIX goes further with support for very advanced features such as SQL server extensions, IIS installations and configuration, performance counters, DirectX checking and other game related tasks, .NET native image generation, COM+, drivers, firewall rules, PowerShell extensions, application closing, management of users, groups, shares and much more. Somewhat involved to deal with, but much more reliable than your own custom actions. Download the latest version of WIX and read the help file Wix.chm - the Wix Schema References section.