PaulG
PaulG

Reputation: 14041

Optionally install components, based on commandline parameter?

Is it possible to create an msi package with WiX that will optionally install components, based on commandline setting?

For example. My msi should always include components:

If the msi is executed without any parameters (eg user double clicks the msi) then we only ever install program.exe and componentA.dll

But if the msi is called passing command line parameters (eg installer.msi /special) then componentB.dll is also installed

Upvotes: 0

Views: 259

Answers (1)

Yan Sklyarenko
Yan Sklyarenko

Reputation: 32270

It sounds like you should put your components into features accordingly. For instance, based on the sample you mentioned, the program.exe and ComponentA.dll is likely a FeatureA, and ComponentB.dll is a FeatureB.

Then, you can control which features to install by passing the appropriate INSTALLLEVEL property value.

The Remarks section in the first article gives a pretty good overview of how you can handle this:

Install Level:

For any installation, there is a defined install level, which is an integral value from 1 to 32,767. The initial value is determined by the INSTALLLEVEL Property, which is set in the Property Table.

A feature is installed only if the feature level value is less than or equal to the current install level. The UI can be authored so that when the installation is initialized, the Installer allows the user to modify the install level of any feature in the Feature Table. For example, an author can define install level values that represent specific installation options, such as Custom, Typical, or Minimum, and then create a dialog box that uses SetInstallLevel ControlEvents to enable the user to select one of these states.

Depending on the state the user selects, the dialog box sets the install level property to the corresponding value. If the author assigns Typical a level of 100 and the user selects Typical, only those features with a level of 100 or less are installed. In addition, the Custom option could lead to another dialog box that contains a SelectionTree Control. The SelectionTree Control then allows the user to individually change whether or not each feature is installed.

Upvotes: 2

Related Questions