Building an MSI File: Visual Studio and Orca - More About Properties
(Page 4 of 6 )
Windows Installer properties are the variables that you use to interact with the installation, such as the ProgramFilesFolder property I mentioned. They’re somewhat similar to Environment variables in the sense that they are text-based variables that define other text, standard ones are provided by Windows, and you can define your own and sometimes set the Windows ones. You’ll be looking at properties in detail later, but be aware that they have some important behaviors:
- Properties are case-sensitive. If you create your own property name and refer to it later, be sure that you get the case correct.
- A property can be public or private. A public property must be in uppercase. If it’s public, you can specify it with a value in a command-line install of a package. Also, because of the way that installations work internally, a public property that you create is also visible throughout most of the installation sequence. You cannot specify private properties in a command-line installation and you can’t propagate them throughout the installation sequences (covered in Chapter 5).
- You can treat properties as if they were logical values or data values. I’ll use the built-in VersionNT property as an example. This property tells you whether the system you’re installing on is in the Windows NT family (NT, Windows 2000, Windows 2003, Windows XP). For example, anything you do that depends on Windows Services can be conditioned on VersionNT as if it were a Boolean-valued attribute. It’s not unusual to see VersionNT as a condition in these situations. However, if you look at the actual value of this property you’ll find it returns the version of the NT family that is running. On Windows 2000 this property has the value 500, and on XP the value 501. In other words, it can be used as a Boolean True/False value even though it contains a version value. If you’re a C programmer, you might be familiar with the idea that a value is True if it is non-NULL in spite of its actual value, somewhat like the behavior of some C language variables.
- The data type of a property is vague. As you’ve seen, you can treat VersionNT as Boolean-valued even if the actual value of it is 500. If you wanted to check if you were running on Windows 2000 or later, you might check for VersionNT>=500. Does this mean it’s a string or a Boolean or a number? In practice it usually doesn’t matter because the context usually defines how the data type works, but this vagueness might well offend you if you are a programmer with a type-safe sensibility.
An installer package—a database—contains a Property table, which is where you can define your own properties if you need to give them default values, and also set values for standard installer properties. You aren’t required to declare your own properties in the Property table. Declare them only if you need to give them a default value, because the act of programmatically setting a property name to a value creates the property on the fly.
Looking at Figure 2-9, you see the Property table of your Notepad package. The table in general is just a list of property names and property values, some uppercase and public, some lowercase and private. Because this list contains both user-defined (added by VS when it built the package) and Windows Installer–defined properties, there’s no way to distinguish between what is a predefined installer property and what isn’t, other than by looking in the SDK to see if it’s defined there. ProductName and Manufacturer are among the standard installer properties that are defined here. Like many other properties, these two end up on the system, where they are available to be retrieved using API calls, or shown to the user in places such as the Add/Remove Programs Control Panel applet. ProductVersion is another installer property that you set, but unlike ProductName and Manufacturer, its value is more than just informational. When you look at upgrades and updating your product, you’ll see that incrementing ProductVersion is a key step in the process.

Figure 2-9. The Property table
One of the key properties in an installation is the TARGETDIR property. This is the property that names the product’s primary installation folder. It usually consists of a concatenation of other standard properties, such as [ProgramFilesFolder][Manufacturer]\[ProductName], which is what VS creates as the default location for the application folder.
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: GUIDs: Product, Upgrade, and Package Codes >>
More Visual Basic.NET Articles
More By Apress Publishing