How to conditionally exclude features from "FeaturesDlg" in WiX 3.0 from managed user action (DTF)

I'm trying to build an installer using WiX 3.0, and I'm not sure about one thing. I would like to use the FeaturesDlg dialog so that users can select objects to install, but I need to be able to conditionally exclude some functions from the list based on some previously entered input, preferably from a managed user action.

I see that if I set the Display attribute from Feature to hidden in the .wxs file, that it does what I want, but I cannot determine how to change this attribute at runtime.

Any pointers would be great.

Edit

I tried using SQL to update the session database, but although I can really remove this function using DELETE FROM Feature WHERE Feature = 'featureId' , if I try to use UPDATE Feature SET Display=0 WHERE Feature='featureId' , I get UPDATE FAILED error. If I try to set the Display value to something other than what is already installed, I get this error.

Removing the ALMOST function is good enough, but I will need to go back and add the function again if the user comes back and changes some input.

+4
source share
3 answers

Well, I think I found the solution by accident. After several experiments, I came across an error message from MSI that described some columns for the Feature table in the current session, as well as a RuntimeLevel column that was not described in any of the documents I could find. So I tried this:

 session.Database.Execute("UPDATE Feature SET RuntimeLevel=0 WHERE Feature='MyFeature'"); 

And it worked; this function is no longer specified in SelectionTree. Then I again executed the same request with RuntimeLevel = 1, and it was specified again.

Since I'm not sure if there are any strange consequences for this decision, I will leave the question open longer, just in case anyone has a โ€œbetterโ€ solution.

+2
source

I needed to do the same and find it ...

Create a property that will be set by CA or whatever ...

  <Property Id='INSTALL_FEATURE_2'>YES</Property> 

Then use the property inside your function ...

  <Feature Id='ASecondFeature' Title='Feature 2' Level='1'> <Condition Level='0'>INSTALL_FEATURE_2 = "NO"</Condition> <ComponentGroupRef Id='secondComponent'/> </Feature> 

Note that the dosent condition directly sets whether the parent is set as with files, etc., it sets the Level attribute in the parent function. Setting it to 0 makes it hidden ... voilร !

+3
source

The above example is the right way to conditionally suggest a function (except that it recommended that the condition be in the CDATA section), however, since you said you want to solve this in your custom action ...

Given this function:

 <Feature Id="MyFeature" Title="My Title" Level="1" > <Condition Level="0"><![CDATA[NOT(INSTALLMYFEATURE~="TRUE")]]></Condition> <ComponentGroupRef Id="MyFeatureComponentGroup" /> </Feature> 

In a managed custom action, you get a Session object. If you want to make this function available to the user, set the INSTALLMYFEATURE property to "True", otherwise set to "False".

 session["INSTALLMYFEATURE"] = "True"; 

or

 session["INSTALLMYFEATURE"] = "False"; 
+2
source

Source: https://habr.com/ru/post/1308431/


All Articles