38

This might be a naive question. I have to manually edit a .WXS file to make it support select features from command line.

For example, there are 3 features in .WXS file.

<Feature Id="AllFeature" Level='1'>

    <Feature Id="Feature1" Level='1'> </Feature>

    <Feature Id="Feature2" Level='1'> </Feature>

    <Feature Id="Feature3" Level='1'> </Feature>

</Feature>

Now, I want to select features from command line. Say, if I type "msiexec /i install.msi FEATURE=A", then "Feature1" and "Feature2" is installed; if I type "msiexec/i install.msi FEATURE=B", then "Feature1" and "Feature3" is installed. In this case, "A" maps to Feature 1 and 2; "B" maps to Feature 1 and 3.

How to accomplish this in WIX?

Morgan Cheng
  • 73,950
  • 66
  • 171
  • 230

3 Answers3

59

The accepted answer already mentions the ADDLOCAL property, but seems to imply that you can select only one feature. You can actually select multiple features by seperating them by commas like this:

msiexec /i install.msi ADDLOCAL=Feature1,Feature2

or

msiexec /i install.msi ADDLOCAL=Feature2,Feature3

Another hint: you can discover these feature names by opening the msi with orca. This is very useful when you want to use these tricks to create a bootstrapper that installs certain features of thirdparty msi packages.

Wim Coenen
  • 66,094
  • 13
  • 157
  • 251
  • The msiexec command that I put was for the question asked, but I agree that you can have multiple features from the command line – CheGueVerra Apr 30 '09 at 13:58
  • Thanks, for mentioning the Orca utility. – Peter Vrabel Jul 17 '13 at 12:13
  • 2
    I will mention a better utility : InstEd It (http://www.instedit.com/) which is free for most common use cases – Nicolas Dorier Oct 19 '13 at 21:57
  • 1
    I run into an issue with multiple features not working. When I tried put them in quotes it worked. E.g.: `msiexec /i install.msi ADDLOCAL="Feature1,Feature3"` – Jaans May 23 '14 at 11:34
  • Disclaimer to above comment regarding quotes for features: This might be a consequence of running this in the PowerShell ISE console though. – Jaans May 23 '14 at 12:17
  • What if you are using burn and have a WiX Bundle that includes this MSI and you want to select features via the Bundle.exe command line? – rharrison33 Jun 24 '14 at 21:41
33

I would change Feature1, Feature2 and Feature3 to Components, then would declare something like this:

<Feature Id="FEATUREA" Title="Super" Level="1" >
  <ComponentRef Id="Component1" />
  <ComponentRef Id="Component2" />
</Feature>

<Feature Id="FEATUREB" Title="Super1" Level="1" >
  <ComponentRef Id="Component1" />
  <ComponentRef Id="Component3"/>
</Feature>

Then to Install either FeatureA or FeatureB

msiexec /i install.msi ADDLOCAL=[FEATUREA | FEATUREB]
CheGueVerra
  • 7,849
  • 4
  • 37
  • 49
  • I am pretty sure it's better to use `ADDDEFAULT` than `ADDLOCAL`, at least in this case since the person asking the question doesn't state explicitly they want to override the feature installation state to be "local" as opposed to leaving the default as marked by feature itself. – Armen Michaeli Apr 30 '20 at 12:32
11

There are a number of properties that can control the install states of Features. Check out this MSI SDK documentation and the links from it: http://msdn.microsoft.com/en-us/library/aa367536(VS.85).aspx

Rob Mensching
  • 33,834
  • 5
  • 90
  • 130