Controlling Conditional Features with a Radio Button - wix

My problem is that I would like to allow the user to install an optional component group based on a radio-button selection.
The radio button and the Condition specified in the Feature are both bound to a Property called "InstallType". InstallType will be set to 1 to install only "client" files, but 2 to install both client and server files.
The conditional installation works correctly, based on the initial value of InstallType, but when the user changes InstallType the new value is ignored.
Here is the code in the dialog:
<Fragment>
<Property Id="InstallType" Value ="1"/>
<UI>
<Dialog
Id ="InstallationTypeDlg" Width ="370" Height ="270" Title ="Test Install Type" NoMinimize ="no">
<Control Id ="Text1" Type ="Text" Text ="Choose Install Type:" Height="17" Width="200" X="10" Y="15" />
<Control Id ="InstallTypeRadioGroup" Type ="RadioButtonGroup" Property="InstallType" X="50" Y="35" Height ="40" Width ="300">
<RadioButtonGroup Property ="InstallType">
<RadioButton Value ="1" Text ="ClientOnly" Height ="17" Width ="90" X="0" Y="10" />
<RadioButton Value ="2" Text ="ClientAndServer" Height ="17" Width ="90" X="0" Y="10" />
</RadioButtonGroup>
</Control>
</Dialog>
</UI>
</Fragment>
And here is the code in Product.wxs:
<Feature Id="ClientOnly" Title="Client Only" Level="1">
<ComponentGroupRef Id="ClientProductComponents" />
</Feature>
<Feature Id="ClientAndServer" Title="Client And Server" Level="0">
<ComponentGroupRef Id="ServerProductComponents" />
<Condition Level="1" >
<![CDATA[InstallType = "2"]]>
</Condition>
</Feature>
As shown, the code will always install the Client files, but never the Server.
If InstallType is initialized as "2", both Component Groups are installed, as expected.
I can force the outcome by hard-coding "true" or "false" in the condition evaluation.
The only thing that doesn't seem to be working is that toggling the radio button has no effect on InstallType as seen inside Product.wxs.
If I put a Text box in a dialog downstream of the radio-button dialog, I can see that InstallType contains the correct value.
I am using WIX 3.10 and VS2015.
Anyone have any idea what's wrong?
All responses appreciated.
Thanks,
Warren

Related

WiX: How to display a Feature element's "description" text?

I'm building an MSI installer with WiX, and the installation requires the user to select from a couple of Features:
<Feature Id='DefaultFeature' Title="Backend Server" Level='1' Absent="disallow" AllowAdvertise="no" Description="Mandatory, must be installed.">
<!-- ... -->
</Feature>
<Feature Id='DatabaseComponents' Title="User Database" Level="1" AllowAdvertise="no" Description="Deselect this to enable Active Directory support instead.">
<!-- ... -->
</Feature>
<!-- more features -->
Note the Description attribute. The documentation says about the Description:
This localizable string is displayed by the Text Control of the Selection Dialog.
But: It's not displayed anywhere:
What am I doing wrong here?
As seen here: Add a dedicated control with type Text to the dialog that holds the SelectionTree, and subscribe to the SelectionDescription event:
<Control Id="ItemDescription" Type="Text" X="215" Y="60" Width="145" Height="120">
<Text/>
<Subscribe Event="SelectionDescription" Attribute="Text"/>
</Control>

Can't set first radio button by default

I am building an installer that contains two radio buttons within a RadioButtonGroup. I create the property that relates to the radio group and give it a default value of 0 (the first radio button). I also look in the registry to see if a previous install set one of the buttons.
<Property Id="MACHINE_TYPE" Value="0" Secure="yes">
<RegistrySearch Id="ExistingMachineTypeProperty" Root="HKLM" Key="SYSTEM\CurrentControlSet\Control\Session Manager\Environment" Name="AGENT_MACHINE_TYPE" Type="raw" />
</Property>
<SetProperty Action="UpdateMachineTypeValue" Id="MACHINE_TYPE" After="AppSearch" Value="{}">MACHINE_TYPE="0"</SetProperty>
The control element looks like this
<Control Id="DbStatsMachineType" Type="RadioButtonGroup" X="20" Y="78" Width="115" Height="50" Property="MACHINE_TYPE">
<RadioButtonGroup Property="MACHINE_TYPE">
<RadioButton Value="0" X="0" Y="0" Width="300" Height="15" Text="Machine A" />
<RadioButton Value="1" X="0" Y="32" Width="300" Height="15" Text="Machine B" />
</RadioButtonGroup>
<Condition Action="enable">DBSTATSENABLED</Condition>
<Condition Action="disable">NOT DBSTATSENABLED</Condition>
</Control>
I am having issues with setting the first radio button by default. If there is no env var AGENT_MACHINE_TYPE, then neither radio button is selected by default. If the var equals 0, neither radio button is selected. BUT, if the var is 1, then the second radio button is selected. What am I doing wrong?
The problem has to do with the time at which the condition is evaluated in relation to your initial value for MACHINE_TYPE.
I've posted an answer before that deals with this issue. Here, take a look. Hope it helps you!

When are property-based values resolved?

I have a wix install file defined with a Property, IniFile inside a Component, and a custom dialog with a RadioButtonGroup that changes the value of said property. The property is used as a value for one of the IniFile's entries. Problem is it seems that IniFile value gets resolved prior to the property getting set via the radio buttons, as I always get the property's default value in my ini file. So my question is - how do I get it to resolve the IniFile's value (a property) later, after it's been altered.
Here's a rough outline of what I have:
<Property Id="SlpStatic" Value="STATIC" />
.
.
<Component Id="UpdateSlpStatic" Guid="aa8867b4-129c-42f3-85cc-06b588c29a40" Directory="TARGETDIR">
<CreateFolder />
<IniFile Id="IniSlpStatic" Action="addLine" Section="Overrides" Name="config.ini" Directory="INSTALLDIR" Key="type" Value="[SlpStatic]" />
</Component>
.
.
<Control Type="RadioButtonGroup" Property="SlpStatic" Id="SlpStaticChoice" Width="200" Height="42" X="112" Y="68">
<RadioButtonGroup Property="SlpStatic">
<RadioButton Text="SLP" Height="17" Value="SLP" Width="300" X="0" Y="0" />
<RadioButton Text="Static" Height="17" Value="STATIC" Width="200" X="0" Y="25" />
</RadioButtonGroup>
</Control>
I know that the SlpStatic property is getting set properly (I have another control that enables/disables based on its value), so the problem is that IniFile's value is getting resolved too early.

WiX installer - Set ApplicationFolder from ComboBox

I'm writing a WiX installer for a group of medical device SW products that must install in specific directories off the root of C:. IE no "ProgramFolders" for these.
They run in dedicated environments and have been verified and validated using these directories.
I have a custom welcome dialog that has a combobox:
<Control Id="TypeCombo" Type="ComboBox" X="178" Y="162" Width="120" Height="20" Property="InstallChoiceResult" ComboList="yes" Sorted="no">
<ComboBox Property="InstallChoiceResult">
<ListItem Text="Base dev 1" Value="1"/>
<ListItem Text="Base dev 2" Value="2"/>
<ListItem Text="Base dev 3" Value="3"/>
<ListItem Text="Base Simulator" Value="4"/>
</ComboBox>
</Control>
The choice by the FSE sets the property "InstallChoiceResult". After they hit next I need to set my application folder based on their choice. IE if they chose "Base dev 1" then I need to set APPLICATIONFOLDER to C:\BASEDEV1. If they choose Base dev 2 then we go to C:\BASEDEV2
Being new to WiX I'm strugging with the sequence. It seems from examining my MSI with Orca that the InstallUISequence comes AFTER the costing occurs. When I try to set the APPLICATION folder using a group of custom actions it complains that since it is a directory it must be set before CostFinalize.
I'm sure I'm missing something simple but if my UI seems to be running AFTER that how can I set the directory I need? My custom actions currently look like:
<CustomAction Id="SetDev1" Property="APPLICATIONFOLDER" Value="C:\BaseDev1" Execute="immediate" />
<CustomAction Id="SetDev2" Property="APPLICATIONFOLDER" Value="C:\BaseDev2" Execute="immediate" />
<CustomAction Id="SetDev3" Property="APPLICATIONFOLDER" Value="C:\BaseDev3" Execute="immediate" />
<CustomAction Id="SetDevS" Property="APPLICATIONFOLDER" Value="C:\BaseDevS" Execute="immediate" />
<InstallUISequence>
<Custom Action="SetDev1" Before="InstallDlg2">InstallChoiceResult=1</Custom>
<Custom Action="SetDev2" Before="InstallDlg2">InstallChoiceResult=2</Custom>
<Custom Action="SetDev3" Before="InstallDlg2">InstallChoiceResult=3</Custom>
<Custom Action="SetDevS" Before="InstallDlg2">InstallChoiceResult=4</Custom>
</InstallUISequence>
The general jest of what I need to do is basically this:
Display dialog (FSE chooses 1, 2, 3 or simulator)
After next is pressed, Set ApplicationFolder based on property from ComboBox
Install into the set ApplicationFolder
Any help would be very much appreciated.
You can set the directory values to APPLICATIONFOLDER using SetDirectory element. No need to use Custom action and bind the directory values directly to the List item. Make the Combo box property is public (All letter in uppercase).
<Control Id="TypeCombo" Type="ComboBox" X="142" Y="158" Width="120" Height="16" Property="INSTALLCHOICERESULT" ComboList="yes" Sorted="no">
<ComboBox Property="INSTALLCHOICERESULT">
<ListItem Text="Base dev 1" Value="C:\BaseDev1" />
<ListItem Text="Base dev 2" Value="C:\BaseDev2" />
<ListItem Text="Base dev 3" Value="C:\BaseDev3" />
<ListItem Text="Base Simulator" Value="C:\BaseDevS" />
</ComboBox>
</Control>
<SetDirectory Id="APPLICATIONFOLDER" Value="[INSTALLCHOICERESULT]" Sequence="execute" />

Wix: Edit Control not setting property

I have an issue with Wix where an Edit control is not setting a property. I am using the property in a XmlFile node to modify an .xml file copied to the install location. The value of the property IS being correctly set in the file (the default value is being used) but I cannot seem to set the property with a value from the Edit control. This is driving me nuts.
<Fragment>
<Property Id="CUSTOMERNAMEPROPERTY" Value="Some default value" Secure="yes" />
<UI>
<Control Id="CustomerNameEdit" Type="Edit" X="120" Y="75" Width="220" Height="18" Property="CUSTOMERNAMEPROPERTY" Text="{80}" Indirect="yes" />
</UI>
</Fragment>
What is wrong with this?
Thanks
The Indirect attribute should be set to "no". Edit controls should reference their properties directly.
Also, make sure that you use a public property (only uppercase letters in its name). Private properties use their default values during install.
Try to declare your property inside <UI> element:
<Fragment>
<UI>
<Property Id="CUSTOMERNAMEPROPERTY" Value="Some default value" Secure="yes" />
<Control Id="CustomerNameEdit" Type="Edit" X="120" Y="75" Width="220" Height="18" Property="CUSTOMERNAMEPROPERTY" Text="{80}" Indirect="yes" />
</UI>
</Fragment>