How to: Set Conditional Installation Based on User Choices

The Condition property can be used to add conditional logic to an installer (for example, to allow a user to choose whether a file will be installed). During installation, the condition is evaluated and the file is installed only if the condition evaluates to true.

The following example illustrates using a RadioButtons User Interface dialog box to conditionally install a file.

Note

The dialog boxes and menu commands you see might differ from those described in Help depending on your active settings or edition. To change your settings, choose Import and Export Settings on the Tools menu. For more information, see Visual Studio Settings.

To install a file based on a user's choice

  1. In the User Interface Editor, select the Start node under Install.

  2. On the Action menu, choose Add Dialog.

  3. In the Add Dialog dialog box, select the RadioButtons (2 buttons) dialog box.

  4. On the Action menu, choose Move Up twice, moving the RadioButtons (2 buttons) node just below the Welcome node.

    Note

    All custom dialog boxes must precede the Installation Folder dialog box (or Installation Address dialog box for a Web Setup project).

  5. Select the RadioButtons (2 buttons) node in the User Interface Editor. In the Properties window, select the BodyText property and describe the choice being presented (for example "Do you want to install the readme file?").

  6. Select the Button1Label property and describe the first option (for example "Install the readme file").

  7. Select the Button2Label property and describe the second option (for example "Do not install the readme file").

  8. On the View menu, point to Editor, and then click File System.

  9. Select a file in the File System Editor.

  10. In the Properties window, select the Condition property and type BUTTON2=1.

    This condition uses the ButtonProperty property (BUTTON2) of the RadioButtons (2 buttons) dialog box, which returns either the Button1Value (1) or Button2Value (2) property depending on which button is selected during installation. If the first button was selected, the condition BUTTON2=1 evaluates to true and the file will be installed.

    Tip

    In the above example, the ButtonProperty property uses the default value "BUTTON2". In most cases, you will want to change this to a more meaningful name such as "InstallReadme".

See Also

Concepts

Deployment Conditions

Reference

Condition Property

Other Resources

User Interface Management in Deployment

File Installation Management in Deployment