Pages

Showing posts with label Windows File Versioning Rules. Show all posts
Showing posts with label Windows File Versioning Rules. Show all posts

Saturday 4 August 2012

Windows File Versioning Rules


Suppose your installation source contains a file named newstuff.dll, and the
Installer finds a copy of newstuff.dll already on the user’s hard drive. How
would you decide whether to overwrite the existing copy on the hard drive with a new copy from the source media? Your first idea might be to compare file dates; you would then overwrite if the copy in the source media was newer. A more sophisticated version of this technique is to look at the internal file version information, and overwrite if the copy in the source media has a higher version.


The Windows Installer uses an even more complex algorithm when deciding
whether to keep an existing file or install a new copy. It takes into account not just the file dates and the version, but the languages involved as well. Here’s the set of rules the Windows Installer follows:

Highest version wins: All other things being equal, the file with the highest
version number wins, whether that’s the file on the hard drive or the file in the
source media.


Any version is higher than no version at all: If the copy in the source media
contains version information, and the copy on the hard drive has no version
information, Windows Installer chooses the one with the version information.


Favor the new language: All other things being equal, if the file being
installed is localized for a different language than the file on the computer, Windows Installer uses the copy with the language that matches the product being installed.


Meet the product’s needs for multiple languages: If both copies support
multiple languages, Windows Installer ignores the common languages and uses the copy that supports the most languages out of the set of languages that the product uses.


Keep the maximum number of languages: If the copies differ in the number
of languages they support and both support all the languages that the product
needs, Windows Installer keeps the copy that supports the most languages.


Treat non-versioned files as user data: If there is no version information for
either copy, Windows Installer compares the file creation date and the last modification date for the file on the computer. If the modification date is later than the creation date, Windows Installer assumes this file has been customized by the user and does not overwrite it. Otherwise, it installs a new copy.


Companion files go along with the versioned file: It’s possible to mark a
file within the Installer database that does not include version information as a companion file to a file that does include version information. In this case, the companion file is installed if the other file is installed. There is one exception to this rule, though. If the companion file is not present on the target machine, it’s installed even if the versioned file is not installed.


It’s a good thing that these rules match the way most developers would like
installations to behave because there’s no way for you to change them. Of course, you can pervert their intention if you feel you must. One way to guarantee that a file from the source media is installed is to set its version string in the File table to 65535.65535.65535.65535, which is the maximum version number that the Windows Installer accommodates. Beware, though: if you do this, you’ll never be able to use the Windows Installer to replace that copy of the file with a new version.


Tuesday 6 September 2011

Windows File Versioning Rules

At the core of any installer is the actual installation of files. But determining whether to install a file is a complex process. At the highest level, making the determination depends on whether the component to which a file belongs is marked for installation. Once the determination is made that a file should be copied, the process is complicated if another file with the same name exists in the target folder. In such situations, making the determination requires a set of rules involving the following properties:
  • Version
  • Date
  • Language
The installer only uses these rules when trying to install a file to a location that already contains a file with the same name. In this case, the Microsoft® Windows® Installer uses the following rules to determine whether to install.


Highest Version Wins — All other things being equal, the file with the highest version wins, even if the file on the machine has the highest version.


Versioned Files Win — All other things being equal, a versioned file gets installed over a non-versioned file.


Favor Product Language — All other things being equal, if the file being installed has a different language than the file on the machine, favor the file with the language that matches the product being installed. Language neutral files are treated as just another language so the product being installed is favored again.


Mismatched Multiple Languages — All other things being equal, after factoring out any common languages between the file being installed and the file on the machine, any remaining languages are favored according to what is needed by the product being installed.


Preserve Superset Languages — All other things being equal, preserve the file that supports multiple languages regardless of whether it is already on the machine or is being installed.


Non-versioned Files Are User Data — All other things being equal, if the Modified date is later than the Create date for the file on the machine, do not install the file because user customizations would be wiped out. If the Modified and Create dates are the same, install the file. If the Create date is later than the Modified date, the file is considered unmodified, install the file.


Non-versioned Files Using Companion — All other things being equal, a non-versioned file that is associated with a versioned file using the companion mechanism abides by the rules for the versioned file. The only exception is if the versioned file on the machine and the versioned file being installed have the same version and language but the companion file is missing on the machine. In this case the companion file being installed is used even though the versioned file on the machine is used.


Rules Are Global — The rules for determining when to install a file reside in one place within the installer and are global, meaning they apply to all files equally.