We've been using WiX for a while now, and despite the usual gripes about ease of use, it's going reasonably well. What I'm looking for is useful advice regarding:
- Setting up a WiX project (layout, references, file patterns)
- Integrating WiX into solutions, and build/release processes
- Configuring installers for new installations and upgrades
- Any good WiX hacks you'd like to share
Best Solution
Keep variables in a separate
wxi
include file. Enables re-use, variables are faster to find and (if needed) allows for easier manipulation by an external tool.Define Platform variables for x86 and x64 builds
Store the installation location in the registry, enabling upgrades to find the correct location. For example, if a user sets custom install directory.
Note: WiX guru Rob Mensching has posted an excellent blog entry which goes into more detail and fixes an edge case when properties are set from the command line.
Examples using 1. 2. and 3.
and
The simplest approach is always do major upgrades, since it allows both new installs and upgrades in the single MSI. UpgradeCode is fixed to a unique Guid and will never change, unless we don't want to upgrade existing product.
Note: In WiX 3.5 there is a new MajorUpgrade element which makes life even easier!
Creating an icon in Add/Remove Programs
On release builds we version our installers, copying the msi file to a deployment directory. An example of this using a wixproj target called from AfterBuild target:
Use heat to harvest files with wildcard (*) Guid. Useful if you want to reuse WXS files across multiple projects (see my answer on multiple versions of the same product). For example, this batch file automatically harvests RoboHelp output.
There's a bit going on,
robocopy
is stripping out Subversion working copy metadata before harvesting; the-dr
root directory reference is set to our installation location rather than default TARGETDIR;-var
is used to create a variable to specify the source directory (web deployment output).Easy way to include the product version in the welcome dialog title by using Strings.wxl for localization. (Credit: saschabeaumont. Added as this great tip is hidden in a comment)
Save yourself some pain and follow Wim Coehen's advice of one component per file. This also allows you to leave out (or wild-card
*
) the component GUID.Rob Mensching has a neat way to quickly track down problems in MSI log files by searching for
value 3
. Note the comments regarding internationalization.When adding conditional features, it's more intuitive to set the default feature level to 0 (disabled) and then set the condition level to your desired value. If you set the default feature level >= 1, the condition level has to be 0 to disable it, meaning the condition logic has to be the opposite to what you'd expect, which can be confusing :)