When are property-based values resolved? - wix

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.

Related

Displaying text inside a control element with type edit

Pretty simple: I would like to have a edit-field where there is already text inside (a kind of default value) but which is also editable.
I tried a lot of different version but nothing wanted to work yet.
This is the last version I tried (the checkbox works just fine):
<Property Id="MYPROPERTY" Value="default" />
<UI>
<Dialog Id="ConfigVariablesDlg" Width="370" Height="270">
<Control Type="Edit" Id="InputField" Property="MYPROPERTY" X="125" Y="27" Width="100" Height="15" Indirect="yes" Text="[MYPROPERTY]">
<Condition Action="disable"><![CDATA[EnableBox<>"1"]]></Condition>
<Condition Action="enable">EnableBox="1"</Condition>
</Control>
<Control Type="CheckBox" Id="MyBox" Width="10" Height="10" X="110" Y="30" Property="EnableBox" CheckBoxValue="1"/>
</Dialog>
</UI>
when you define your property you simply have to assigne it a value like this
<Property Id="MYPROPERTY">Text you want to fill in</Property>
So you cut away your Value Field from your Control Element and define your Property beforehand. (Still Inside your UI Element!)
So in the end your code should look something like this
<UI>
<Property Id="MYPROPERTY">Text you want to fill in</property>
<Dialog Id="ConfigVariablesDlg" Width="370" Height="270">
<Control Type="Edit" Id="InputField" Property="MYPROPERTY" X="125" Y="27" Width="100" Height="15" Indirect="yes">
<Condition Action="disable"><![CDATA[EnableBox<>"1"]]></Condition>
<Condition Action="enable">EnableBox="1"</Condition>
</Control>
<Control Type="CheckBox" Id="MyBox" Width="10" Height="10" X="110" Y="30" Property="EnableBox" CheckBoxValue="1"/>
</Dialog>
*edit also I am pretty (but not entirely sure)
![CDATA[EnableBox<>"1"]]
should be
![CDATA[EnableBox<>1]]
atleast thats how it worked for me

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!

Controlling Conditional Features with a Radio Button

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

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>

wix getting user input

Dialog.wxs
<UI>
<Dialog Id="UserRegistrationDlg" ... >
<Control Id="NameEdit" Type="Edit" X="45" Y="85" Width="220" Height="18" Property="NameValue" Text="{80}" />
</Dialog>
<UI>
In Product.wxs I created a property
<Property Id="NameValueProperty" Value="NameValue" />
Then, as I understood, I have to use [NameValueProperty] for getting value but id doesn't work ... What's wrong?
A verbose log file should show you the changes to the properties. Very useful when tracking down these sort of things. In this case, your example code is actually setting a Property called NameValue to the value in the edit box. If you want to default the value in the edit box then you would do something like:
<Property Id="NameValue" Value="Show this in the edit box" />
And to reference the value you'd use [NameValue]. Alternatively, you could change your code to be:
<UI>
<Dialog Id="UserRegistrationDlg" ... >
<Control Id="NameEdit" Type="Edit" X="45" Y="85" Width="220"
Height="18" Property="NameValueProperty" Text="{80}" />
<Dialog>
<UI>
You generally want to use a Secure Custom Property in this situation. This is a property that is both Public (i.e. CAPS ) and marked as Secure A value is only required if you want there to be a default value.
<Property Id="MYPROPERTY" Secure="yes" />