Wednesday, October 19, 2011

WiX: Property scope

Working on my WiX-based installation project I discovered very important feature. By default, properties are not public, meaning that they are not available when the installer runs through its execution phase (when changes are made to the end user's system). To use properties when writing to the Registry, laying down files and any other act that changes the user's computer, these properties must be declared as public.

There are no special attribute for the property tag to make it public. Making property public is just a matter of making its Id all uppercase, e.g. MY_PROPERTY is public, while myProperty or my_Property are not. One example of when to do this is when you collect information from the user with a dialog and then want to take some action on it during the execution phase such as store it in the Registry.

The following property, because it's uppercase, will persist throughout  the entire installation:
<property id="MY_PROPERTY" value="my string" />

However, this will not:
<property id="My_Property" value="my string" />

You could consider this a private property. It will only last during the current session.

No comments: