Tao of the Windows Installer, Part 2
Sticking strictly to the "approximately weekly" schedule, here we have, nearly two weeks later, the somewhat more substantial second part in this series.
Thanks for the comments on Part 1 - even though I briefly answered some at the time, I'll be using these when I come to re-draft the list. So, please keep the comments coming, they are useful.
Series links:
Packaging Rule 7: Work On a Copy
"My file server won't boot and I really need it up and running now!""Ok, let's re-install Windows and restore the data from backup.""What backup ...?" Been there? Done that? While losing a single MSI package might not be as disastrous as losing your file server, you really don't want to start from scratch because of some accidental corruption. So, always make a copy of your package before you start work, then work on the copy. That way, it is easy to revert to a known good version if the working one becomes corrupt or has other problems you cannot easily correct.Rule 8: Never Cancel a Package Build Before it Finishes To avoid corrupting a package, allow the packaging tool to finish building any new version once initiated. Even if you realise that you need to make more changes or did something wrong, allowing the package to build rather than stopping part way through helps avoid possible corruption. Obviously, if the package does become corrupt, all is not lost if you followed Rule 7.Rule 9: Use a Clean System for Repackaging Rule 10: Do Not Repackage Microsoft Updates Microsoft uses a different packaging technology to create Service Packs and other updates for many products, including Windows, Internet Explorer, Exchange Server, SQL Server and ISA Server. This technology is not related to the Windows installer and it is completely unsupported to convert the updates to Installer packages. Refer to the following article for support details: Repackaging software updates to use Windows Installer is not supported You may be aware that Windows Service Packs ship with an “Update.msi” package that can be used to deploy the Service Pack via Group Policy. This package simply calls the normal .exe-based install as a custom action. This is the only supported use of this package and it is not supported to create your own similar MSI wrapper for Service Packs or other updates. Apart from the one situation mentioned, deploying updates in this way is not tested by Microsoft and the results cannot be guaranteed and hence are unsupported.Rule 11: Do Not Repackage MSI-Based Applications The Installer does not just copy files and registry keys to the target system. It also creates a lot of “configuration data” to help it keep track of the components, features, etc. If you use a “snapshotting” technique to repackage an MSI-based application your package will include all of this extra data, which it will treat as normal files and registry information. However, this will almost certainly lead to serious problems with the Installer, since this data is actually Installer data from another install.Rule 12: Modify Vendor Packages Using Transforms As previously mentioned vendor may not support re-packaging their legacy packages. It is also possible that they will not support direct modification of their MSI packages either. For example, Microsoft does not support customisation of Office installations by editing the Office MSI package. The recommended (and more likely to be supported) method of modifying vendor packages is via transforms. You can create these in all major packaging tools or by using the MsiTrans.exe tool that ships with the SDK. You should also consider the use of transforms for customising your own packages. Using this technique you can have a single base package that can be deployed to a variety of clients, with customisation handled via one or more transforms.Rule 13: Be careful with Installer GUIDS The Installer uses GUIDs to uniquely identify applications, packages, features, etc. For example, the ProductID is the GUID used by the Installer to distinguish one application from another. It doesn’t matter if the package or application names for two different applications are different, if the IDs are the same, the Installer is likely to become confused and you will encounter problems with installation, repair and uninstall. You can use the same ProductID when a package is a newer build of an existing one, but you need to then have different PackageIDs to distinguish the application versions. If you want the packages to be upgrades of each other, then you need them to have the same UpgradeID. GUIDs should be all uppercaseRule 14: Use Consistent Package Naming Conventions The name of the MSI package itself doesn’t really matter as far as the Installer is concerned. As Rule 13 mentions, the Installer uses GUIDs to identify packages, etc. However, while the Installer doesn’t care about the original MSI name, once it registers that name for the product, it does care. Any small and/or minor update that is issued via an MSI must use the same base package name (the source location can be different depending upon source policy, but the base package name must be the same). Also, package naming is important from a user point of view. Consistent, user-friendly naming allows the user to identify a package's contents from the name alone. For example, the following convention can be useful in a corporate environement where there may be many in-house packages available to users: <Application Vendor>_<Product Name>_<Product Version>_<Department>.msi Following this, a repackaged version of Adobe Acrobat Reader v7.1 available to all users would be named: Adobe_AcrobatReader_71_ALL.msiRule 15: Do Not Try to Replace Protected System Files Since the release of Windows 2000, Windows has shipped with Windows File Protection (WFP) , a mechanism for monitoring and restoring system files that have been renamed, deleted, etc. The Installer has no mechanism for by-passing WFP and if your package attempts to replace a protected file, the installation may not give the expected result. For the sake of application compatibility, the install does not fail if it is unable to update a WFP file. Instead, an entry is written to the application event log. However, it is important to note that the application may not be using the intended version of the file. Do not be tempted to work around this by using a custom action or other means. WFP will roll-back any changes you make. In any case, even if you managed to force your changes onto the system replacing protected files is simply unsupported by any means except Microsoft-approved methods. For example, by installing a Service Pack.Rule 16: Follow Component Rules Rule 17: Understand File Versioning Rules The Installer has strict rules that it follows when determining whether to replace an existing file or not. File version, timestamp and language are all used to determine what to do in most cases. It is particularly important to understand what happens with unversioned files. Generally, these are treated as user data, and if any modification has taken place since the original install the Installer will not over-write. Refer to the SDK for full details of the versioning rules.Rule 18: Improve Performance by Limiting System Restore During Setup In a corporate environment where re-imaging or some other technique may be the preferred method for workstation recovery, and System Restore is never used, the additional time and disk space required to create the System Restore Points is essentially wasted. Turning it off for Installer activity will improve performance. You can turn off System Restore snapshots for installation using this per-machine policy setting: HKEY_LOCAL_MACHINE\Software\Policies\Microsoft\Windows\InstallerLimitSystemRestoreCheckpointing = 1 This setting is affects only Installer-initiated restore activity and is available in Group Policy to aid its deployment to workstations. Note that System Restore is a very important feature of Windows and in most circumstances it is recommended that you do not switch it off, so this rule is only applicable for corporate scenarios where this feature is not used.Rule 19: Avoid Using the SelfReg Table Rule 20: Avoid Nested Installs Rule 21: Avoid Using Configuration Data You Don’t Own As part of the initial design for the Installer, the consistency of installations was achieved via Microsoft taking ownership of the code for the install engine. This includes the location and format of all configuration data. This data is managed by the Installer and direct access by users or applications is discouraged; in fact some of the data is encoded to make it very difficult to manipulate manually. You should not try to peek directly into Windows Installer configuration information. Instead, use the Windows Installer API to get the information you need. Accessing the data this way ensures that your package or application will continue to work even if the underlying configuration data changes location or format.Rule 22: Differentiate Between User and Application Data All user registration data should be written to the HKEY_CURRENT_USER hive and application data to the HKEY_LOCAL_MACHINE hive. Also, your package should avoid over-writing user data during install, repair, etc. The user doesn’t want to have to re-configure their user-specific application settings after they repair the application.Rule 23: Don’t Use Resources You are Installing It is generally not a good practice to rely on the installation of certain non-critical resources. For example, a custom action that relies on the installation of a file that is part of an advertisable feature might fail when a user chooses to advertise the feature. Another typical scenario is a custom action sequenced ahead of InstallFinalize that uses methods exposed by an assembly that your setup is installing. Since assemblies are not committed to the GAC until towards the end of InstallFinalize, you can not use them until after that point.Rule 24: Use Cabinet Files to Reduce Package Sizes The Installer allows for packages to contain compressed and uncompressed source files. Compressing the files and storing them in a cabinet (.cab) file reduces the size of the package. The Installer allows the .cab file to be stored as a separate external file, or as a data stream in the MSI package itself. Note that for extremely large packages (i.e. with more than 32767 files), you must alter the schema to increase the number of files allowed. The steps to do this are documented in the SDK.Rule 25: Follow Custom Action Rules Rule 26: Consider Storing User-specific Data in a File Rule 27: Consider Maintaining Setup in Text File Format Many authoring tools such as the WiX toolkit now have underlying formats that permit building from text files. This makes viewing setup changes a lot easier and may be somewhat more intuitive for developers already used to dealing with version-controlled text files when writing application code. WiX is free and gives you the ability to stay very close to the Windows Installer technology without having to worry about every tiny detail (such as keeping foreign keys cased correctly).Rule 28: Think about Localisation What if your package is English and a user in China installs it onto a Chinese system? In order to anticipate and cope with such situations learn about Installer properties like ProductLAnguage, Template Summary information property, code pages of the database and summary information for the package. You should prepare for localization when authoring the original installation package. Design the layout of localised files such that different language versions can safely coexist when installed on the user’s computer. Organise files requiring localization into separate components and install these files into separate directories.Rule 29: Follow the Assembly Rules
|
[Author: Richard Macdonald]
This posting is provided "AS IS" with no warranties, and confers no rights.
Comments
- Anonymous
May 12, 2006
In regard to Rule 14, Use Consistent Package Naming Conventions, can you elaborate on what constitutes a "base package name"? That phrase doesn't appear anywhere in the Windows Installer 3.1 Help file. For example, does MyApp_v1.00.MSI have the same base package name as MyApp_v1.01.MSI? How much latitude is there in the naming convention without breaking this rule? - Anonymous
May 13, 2006
Hi Rick
I would suggest that base package name refers to the actual msi file (I think the SDK actual refers to it as the package database from memory?).
What you can't do is name the MSI file Blah_v1.msi then patch the install point, rename it to Blah_v1a.msi and expect clients to be able to redeploy/install updated features only.
Personally, we use the folder name to identify the package and name all our base package files "setup.msi" (we agree with all the other points though!)
Hadn't yet considered point 18 (turning off system restore) - although given the environment we work in I have already emailed a link to my colleagues. - Anonymous
May 14, 2006
I think that "base package name" means the name of the .msi file that was used for the original/initial install (the "base package"). Small and Minor updates ("update packages") must use the same .msi file name as the base package. - Anonymous
May 15, 2006
The comment has been removed - Anonymous
May 16, 2006
I have a suggestion for a new rule:
"Design and test your servicing strategy before you ship the initial product. You must know in advance how you'll be updating your product, and once it's shipped it's too late to change its design. So build and install your product, then create an update (a patch, a minor update, a major upgrade, whatever you'll be using) and make sure that it actually works."
I've lost track of the number of times I've seen people ship the product then run into a servicing issue because the product has been shipped and it's too late to change that original design. - Anonymous
May 16, 2006
The term ‘base package name’ is not used in the SDK documentation and notice that a definition of ‘base package’ does not appear in the glossary. The phrase ‘base package’ appears in various parts of the documentation describing customization and instance transforms. It has been used to mean the target or unmodified version for a transform.
As general advice to users of the documentation – If a term is not in the glossary, or does not appear in a SDK topic title, it has not been defined precisely. So expect the words were used in their ordinary sense.
My understanding of Rule 13 and Rule 14 is that these could be combined:
Rule 13.5 – Keep application identifiers consistent
The product code GUID is the principal identification of an application and must change whenever there is a comprehensive update to the application. Changing the name of the application’s .msi file is considered a comprehensive change and always requires a corresponding change of the product code to maintain consistency. The .msi file can be given any name that helps users identify the package, but the name should not be changed without also changing the product code. - Anonymous
May 16, 2006
I second that! In general I recommend that you use your msi installer during the beta phase of the product, and ship (at least some) beta updates as msi updates/patches. - Anonymous
May 16, 2006
The comment has been removed - Anonymous
May 23, 2006
The comment has been removed - Anonymous
May 23, 2006
The comment has been removed - Anonymous
May 23, 2006
The comment has been removed - Anonymous
May 23, 2006
The comment has been removed - Anonymous
July 08, 2006
I recently noticed a series of in-depth articles that have been posted on the Windows Installer team... - Anonymous
September 18, 2006
PingBack from http://blogs.msdn.com/windows_installer_team/archive/2006/06/27/648447.aspx