views:

484

answers:

1

What is the Wix 'KeyPath' attribute? In particular, how does it apply to the following:

            <Component Id="ProgramMenuDir" Guid="BF266F76-192A-493E-B5C7-C54660E61D7D">
                <RemoveFolder Id="ProgramMenuDir" On="uninstall" />
                <RegistryValue Root="HKCU" Key="Software\CompName\AppName" Type="string" Value="" KeyPath="yes" />
            </Component>
+7  A: 

As explained by Rob Mensching:

The KeyPath for a Component is a single resource that the Windows Installer uses to determine if a Component "exists" on a machine.

This means that when Windows Installer decides whether to install your component, it will first look whether the keypath resource is already present. If it is, none of the resources in the component are installed.

The presence of the keypath resource also determines whether a component has been damaged or has gone missing when you "repair" an MSI.

When the keypath resource is a versioned file, Windows Installer will consider it to exist only if it finds a file with an equal or higher version.

In your specific example, you have a component which removes a folder on uninstallation. This component will only be installed if the given registry key does not yet exists. Adding a registry key to use as the key path is a common trick when you need a keypath for a component that installs resources that cannot be used as a keypath themselves, like a shortcut.

Wim Coenen
So then what is the point in explicitly giving the only file in a component a keypath="no" attribute?
Adkins
@Adkins: that would supress the default behavior of wix to take that file as the keypath. As a result, no keypath is written to the installer database for that component. During installation, windows installer will then use the *destination folder* of the component as the keypath. Another way to get this behavior is to set "keypath=yes" on the component element itself. In any case, it doesn't seem like a good idea to me.
Wim Coenen