Friday, March 09, 2007

Features and Components

Windows Installer categorizes the elements of an application or product into three containers: components, features, and products:

Component:
A Windows Installer component is a collection of files, registry keys, and other resources that are installed or uninstalled together on the client computer.
A component is the smallest separately installable piece of a product from the setup developers standpoint. All of the contents of a component must be installed to the same directory and under the same conditions. There is no mechanism for installing a part of the component. The user never interacts with the component. Components are part of the features. For a component to be installed it should be present in a feature. Components contain the data installed by application files registry information, ini data, com information, environment variables and so forth. Every component should have a key path (usually key file) defined. A key file is the most important file in the component; a windows installer repair / or self repair operation will repair the component only if its key file is missing from the target system. Typically, the keypath is a file; component can also have a registry value as its key path but not both at the same time.
A resource can be part of only one component. For example, no two components share the same file, whether they are part of the same product or parts of different products. To include a common file, two applications must include the same common component. Because of this restriction, components are typically small, consisting of a file and other resources that are tightly coupled with it, such as registration information.
The Windows Installer service checks for the existence of the keypath resource when verifying that a Windows Installer component is properly installed. If for any reason the keypath resource is missing, the Windows Installer service treats that component as broken and self repairs the application.
A component is globally unique, meaning that a single component is guaranteed to always contain the same set of resources in any application that includes it. To maintain global uniqueness, each component is assigned a globally unique identifier (GUID), known as the Component Code. The Component Code prevents collisions between components that must be distinct
Windows Installer components also overcome a traditional limitation of the operating system by allowing you to manage resources other than files. Installation software manages shared files by maintaining a shared reference count (refcount) in the system registry for each shared file, not by removing a file until that refcount reaches zero. However, this does not apply to other resources, such as registry keys, because there is no mechanism for maintaining a shared refcount for them.

Because the Windows Installer service maintains a shared count at the component level instead of at the file level, and because components are minute units, a proper refcount is maintained for all resources. The Windows Installer service removes a component only when no applications remain that depend on that component.

Windows Installer maintains component recounts in the form of a client list of product codes, instead of a numerical list. This means that Windows Installer can identify clients of the resource as well as keep reference counts current.

Features
Windows Installer features are groupings of components. Features are the granular pieces of an application that a user can choose to install, and typically they represent the functional elements of the application, such as the spelling checker in Microsoft Word.
A feature is the smallest Seperately installble collection of data from the end-users stand point. Many third party MSI setups display a custom setup dialog box in which the user can select what parts of the product to install. Features can contain Subfeatures, sub- sub features and so forth.
The Windows Installer service performs all management at the component level, eliminating the need for a feature to have exclusive ownership of its components. Two features in the same or different applications can share a given component without affecting Windows Installer management scheme. Thus, it is not necessary for a feature to be globally unique; so features do not have GUIDs.

Windows Installer enables features to be set to one of four states:
· Installed on Local Hard Disk. The files are copied to the hard disk of the local computer.
· Installed to Run from Source. The application accesses the files from the source, typically, a CD or a network share.
· Advertised. The files are left on the source, but can be automatically copied to the client computer the first time the user selects the feature.
· Not Installed. No files are copied.
Advertising a product merely installs desktop and Start menu shortcuts, file name extension associations, or OLE registration entry points to that product. When a user invokes the application from one of the entry points, the operating system contacts Windows Installer service to install the advertised product. After the installation is completed, the Windows Installer service returns the path for the newly installed application back to the operating system, which then launches the application

Product
A Windows Installer product can represent a single product such as Microsoft Visio, Microsoft Office, or some other software application. Products consist of one or more Windows Installer features. Each product describes itself to the Windows Installer service in the form of a single .msi package file. Products do not directly own any resources, but they do have GUIDs known as Product Codes.

These Product Codes enable the Windows Installer service to uniquely identify applications that are clients of a given component, (by maintaining a list of client products for each component) and to quickly determine if a product is already installed on a particular computer.

For the purposes of this example, Figure Below shows the relationships of a subset of components, features, products, and resources of an actual product. An actual product would contain more features and components, as well as subsets of each feature and component.