I am trying to put together an installer using WiX 3.0 and I'm unsure about one thing. I would like to use the FeaturesDlg
dialog to allow the users to select features to install, but I need to be able to conditionally exclude some features from the list based on some input previously received, preferably from a managed Custom Action.
I see that if I set the Display
attribute of a Feature
to hidden
in the .wxs file that it does what I want, but I can't figure out a way to change that attribute at runtime.
Any pointers would be great.
Edit:
I tried using SQL to update the session Database, but while I can actually delete the feature using DELETE FROM Feature WHERE Feature = 'featureId'
, if I try to use UPDATE Feature SET Display=0 WHERE Feature='featureId'
, I get an UPDATE FAILED
error. If I try to set the Display
value to anything other than what it's already set at I get that error.
Deleting the feature is ALMOST good enough, but I would need to be able to go back and re-add the feature if the user goes Back and changes some input data.
Well I think I found a solution by accident. After a bunch of experimenting I ran across an error message from MSI that kinda described some columns for the Feature table in the current session, and there was a column "RuntimeLevel" that is not described in any docs that I could find. So I tried this:
session.Database.Execute("UPDATE Feature SET RuntimeLevel=0 WHERE Feature='MyFeature'");
And it worked; the feature was no longer listed in the SelectionTree. Then I ran the same query again with RuntimeLevel=1, and it was listed again.
Since I'm not sure if there are any strange implications for this solution I am going to leave the question open for a while longer, just in case somebody else has a "better" solution.