Runar Ovesen Hjerpbakk

Science-based software development

A few drops of WiX wisdom

WiX can hardly be called a beginner friendly framework. Having used the framework for the last couple of days, here are a few tips and tricks I have picked up:

Checking the .Net version

Using the following, the installer fetches the version of the installed .Net framework. If the version matches the requirements all is well. If an older version is installed, the specified message is displayed. This will only inform the user of the missing installation, however, using a bootstrapper the framework (or other dependencies) can be installed together with your MSI.

<Condition Message='.NET Framework 4.0 must be installed prior to installation of [ProductName].'>
MsiNetAssemblySupport >= "4.0"
</Condition>

Upgrades

<Product Id="*" UpgradeCode="GUID" ... >

<Upgrade Id="GUID">
<UpgradeVersion OnlyDetect="no" Property="PREVIOUSFOUND"
   Minimum="1.0.0.0"  IncludeMinimum="yes"
   Maximum="THISVERSION" IncludeMaximum="no" />
</Upgrade>

GUID is the upgrade code of your product. THISVERSION is the current version of the MSI.

<InstallExecuteSequence>
   <RemoveExistingProducts After="InstallFinalize"></RemoveExistingProducts>
</InstallExecuteSequence>

Scheduling the removal of the old version after InstallFinalize assures that only files that actually have changed are being replaced.

Logging

In order to troubleshoot a MSI installation, you need to turn on the log file. The easiest way is using this command:

msiexec /i product.msi /L*v log.txt

product.msi is the MSI to be installed, L means generate a log using v verbose logging and write to file log.txt.

Resources

WiX tutorial is a great tutorial, going from a simple installer to a mature package supporting upgrade with custom made UI.

Using WiX you are never alone and Stack Overflow contains a range of WiX related questions and answers, together with tricks and tips.

<< Older