Building an MSI File: Visual Studio and Orca - GUIDs: Product, Upgrade, and Package Codes
(Page 5 of 6 )
You can see in Figure 2-9 that the ProductCode property is in fact a GUID, a unique identifier made famous by its use in identifying COM classes and interfaces. It’s used here simply because it’s a convenient mechanism to identify the product uniquely. It’s in what is called the Registry format—text with curly braces around it. Windows uses the ProductCode property to identify this product uniquely, and the Windows Installer Service uses it to determine whether your product is already present on a system.
The UpgradeCode is also a GUID that you should not change within the lifetime of a product. The idea behind UpgradeCode is that you will have major revisions to a product over time, and each of these revisions is intended as a replacement for the previous version. The UpgradeCode is the constant that links these revisions together. You can think of an UpgradeCode as defining a product family. Windows can detect whether a product containing a particular UpgradeCode has already been installed on a client system. It provides a mechanism to uninstall the prior version as you install the new version, so that the replacement is a seamless process instead of a visible uninstall followed by an install of the newer product. Each version replaces the prior version until a product arrives that is completely independent of the previous versions. In practice, this might be a marketing decision as much as a technical one. For example, each new version of Microsoft Office that comes out is a replacement for previous versions. However, if you look at the VS product line, VS.NET was the start of a different product line—it did not replace VS 6.0 but could be installed alongside it. If you were designing these product lines, the versions of Microsoft Office would all use the same UpgradeCode, but VS.NET would have a different UpgradeCode than VS 6.0. The way you build an installation to perform a major upgrade of a previous version is covered in Chapter 6.
Each individual package—the MSI file—is also identified by a GUID—the PackageCode. This is used to distinguish between different builds of the same product. If you run Orca on an install package and choose Summary Information from the View menu, you see something like Figure 2-10. This shows the contents of the Summary Information stream for this package, and it includes the PackageCode. (You can also see a similar display when you choose Properties and Summary from the context menu when right-clicking a package, except that the PackageCode is reported there as Revision Number.)
The combination of ProductCode and PackageCode is the way Windows knows what to do if you try to reinstall the product. If you install your Notepad package that you built in this chapter, then try to install the exact same package again, you see that it shows a maintenance mode dialog. In this Notepad installation, this means that the setup shows a dialog with choices for Repair or Remove. Windows knows that this product from this package is already installed on the system, and the package itself is designed to go into this maintenance mode if the product is already installed on the system. By definition, the fact that you are attempting to install the same product (same ProductCode) from the same package (PackageCode) means that you either want to repair or remove it. No other choices make sense in this context—the product is already installed, after all!
You can change the PackageCode by altering the Revision Number from Explorer (right-clicking, choosing Properties and the Summary tab) or in the Orca view of the Summary Information, then closing and saving the file. When you attempt to install this package now, you see different behavior. This time there is a message box from Windows saying that “Another version of this product is already installed” and suggesting that you reconfigure from Add/Remove Programs. In other words, you have to configure or remove the existing installed product before you can install the new one. The PackageCode determines the initial behavior here. If you change only the ProductCode in the Property table using Orca and then try to install the package, it would go into maintenance mode and ask for a Repair or Remove. If you change the ProductCode and the PackageCode, Windows thinks it’s a totally new product and lets you go ahead with the installation.
Figure 2-10. MSI file summary information
If you have built a genuinely new package containing new files, you’ve probably done so to have it update or replace the existing product on the system. This is the subject of Chapter 6. For now, the point of this exercise is to demonstrate the relationship between PackageCode and ProductCode.
This is from The Definitive Guide to Windows Installer, by Phil Wilson, (Apress, ISBN: 1590592972). Check it out at your favorite bookstore today. Buy this book now. |
Next: Into the Package with Programming >>
More Visual Basic.NET Articles
More By Apress Publishing