What do I need to know to understand Windows Installer File versioning rules?
When working with Windows Installer-based installations, knowing basic Windows Installer versioning rules helps predict how an .MSI should function on the destination computer. Because Windows Installer versioning rules work differently than most legacy script-based installation tools, understanding and using the Windows Installer rules can mean the difference between an installation that works and one that does not.
Controlling File Versioning Settings
Windows Installer provides a special property that controls the application of versioning rules to installation files. Setting the property REINSTALLMODE to various values affects how Windows Installer decides which files to replace and which to ignore during installation.
The default value of REINSTALLMODE is omus, which tells Windows Installer to replace only older files during installation. The REINSTALLMODE settings are made up of four letters explained in the following table:
Linking Multiple Files
Another way to control file installation is to link two or more files together as a unit and make the installation of those files depend on the versioning rules of one of the files in the group. For example, assume that your .MSI contains an .EXE and a .DLL. Because when the .EXE changes, the .DLL also changes, you want to group these files so when the .EXE installs, the .DLL installs regardless of the version information.
To do this, use a Windows Installer feature called Companion Files. In the File table of the .MSI, enter that name of the .EXE in the Version column. At installation time, Windows Installer, by using versioning rules, determines whether to install the .EXE. Based on those rules, Windows Installer installs or doesn't install the .EXE and .DLL files together regardless what the independent versioning rules on the .DLL would have normally decided.
Installing Versioned Files
As previously mentioned, REINSTALLMODE controls how versioned files install on the destination computer. For most versioned file installations, the following rules affect the installation:
Installing Non-Versioned Files:
Installing non-versioned files with Windows Installer differs from legacy script-based installation tools. Most users expect the file with the most recent date and time to be installed. However, Windows Installer does not use this method to determine non-versioned file installation and instead uses a two-step procedure.
First, Windows Installer compares the file's unique hash value generated for its content with the MsiFileHash table in the .MSI. If the hash values match, then Windows Installer determines the files are the same and does not replace the file on the destination computer.
If the hash values differ, Windows Installer compares the date/time stamp of the file on the computer. If the file's modification date is newer than its creation date, Windows Installer determines the file contains user-modified content and does not replace the existing file. To override this behavior, use companion files.
By understanding how Windows Installer handles different file-replacement scenarios, you can create a package that installs in a predictable manner. For more information about file versioning rules, see the topic titled File Versioning Rules in the Windows Installer SDK.