Wix: Checkbox to modify PATH environment variable - wix

In the Wix installer toolset, I'm trying to modify the PATH environment variable, depending on a checkbox.
Basically, the modification of PATH looks like this:
<Component Id='EnvVars' Guid='{8046-41E86196A926}'>
<CreateFolder />
<Environment Id='PathEnvVar' Action='set' System='yes' Name='PATH' Part='last' Value='[APPLICATIONFOLDER]'/>
</Component>
I have a checkbox that looks like this:
<Control Id="EnvPath" Type="CheckBox" X="10" Y="83" Width="180" Height="20" Property="ENV_PATH_MODIFY" CheckBoxValue="1" Text="Add to PATH" />
How do I connect the checkbox to the environment variable component so that the checkbox decides whether to execute the component (which modifies the PATH var)?

You can add install condition to your component directly
<Component Id='EnvVars' Guid='{8046-41E86196A926}'>
<CreateFolder />
<Environment Id='PathEnvVar' Action='set' System='yes' Name='PATH' Part='last' Value='[APPLICATIONFOLDER]'/>
<Condition>
ENV_PATH_MODIFY = 1
</Condition>
</Component>

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>

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- Unable to write to XML file when using Property Name as Value

I am trying to write a value into an XML file during the installation, this value comes from a text field which user fills it during the installation stage.
In my GUI file for the installer I have the following EditField:
<Control Id="LogEdit" Type="Edit" X="45" Y="155" Width="100" Height="18" Property="LOGVALUE" Text="{80}" />
In my Product.WXS I have added a new property like below :
<Property Id="LOGVALUE" Secure="yes"/>
<SetProperty Id="LOGVALUE" Value="" After="AppSearch">LogValue</SetProperty>
And then I have created a new component like below:
<Component Id="LogComponent"
Guid="87F682A6-1CC0-4E2D-9882-25D765478F94" Directory='ContentDir' NeverOverwrite='yes' Permanent='yes'>
<File Id="Logconfig"
DiskId="1"
Name="log.xml"
Source="..\bin\log.xml"
Vital="yes"
KeyPath="yes" />
<util:XmlFile Id="SetKey3"
Action="setValue"
ElementPath="/log/appender[\[]#type='log4net.Appender.RollingFileAppender'[\]]/file/#value"
Value="[LOGVALUE]"
File="[#Logconfig]"
SelectionLanguage="XPath"
Sequence="1" />
</Component>
I have also added reference of this component into the .
The problem is after installation nothing will be written into the XML file, However if I replace Value="[LOGVALUE]" with some hardcoded values like Value="TEST" in the util:XmlFile section it works. Any ideas where the mistake comes from?
You are setting the value of LOGVALUE to "" within the below setproperty I believe that is breaking it by setting the value to nothing, set it to "[LOGVALUE]" or don't set it at all as the UI is setting the property value
<SetProperty Id="LOGVALUE" Value="" After="AppSearch">LogValue</SetProperty>

WiX Conditional Registry Entries

I'm working on my first ever WiX project and I'm having a tough time getting some registry entries to work properly.
My requirements are, to have an option in the setup to choose whether the software will be installed on a desktop computer, or on an aircraft. Since there isn't really any way to detect it automatically, I've created an additional UI screen with some radio buttons. (this is in a separate file)
<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Fragment>
<UI>
<Dialog Id="AircraftDesktopDlg_Custom"
Width="370"
Height="270"
Title="!(loc.InstallDirDlg_Title)">
<Control Type="RadioButtonGroup"
Property="InstallType_Prop"
Id="InstallType"
Width="200"
Height="42"
X="20"
Y="110">
<RadioButtonGroup Property="InstallType_Prop">
<RadioButton Text="Aircraft"
Height="17"
Value="0"
Width="50"
X="0"
Y="0" />
<RadioButton Text="Desktop"
Height="17"
Value="1"
Width="200"
X="0"
Y="20" />
</RadioButtonGroup>
</Control>
</Dialog>
</UI>
</Fragment>
</Wix>
Code Listing 1 - Radio Buttons
Then, over in my main Product.wxs file, I have the following.
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product>
<Property Id="InstallType_Prop"
Value="0"/>
.
.
.
<DirectoryRef Id="TARGETDIR">
<Component Id="AircraftRegistryEntries"
Guid="E251C37B-2A4F-46D4-8E9F-24C66FB107E9">
<Condition>InstallType_Prop = 0</Condition>
<RegistryKey Root="HKLM"
Key="Software\Company\Product\v1.0"
Action="createAndRemoveOnUninstall">
<RegistryValue Type="integer"
Name="OfflineMode"
Value="0"/>
<RegistryValue Type="integer"
Name="Simulator"
Value="0"/>
</RegistryKey>
</Component>
<Component Id="DesktopRegistryEntries"
Guid="CACDBBB6-BCAA-4B71-92BE-C762325580A3">
<Condition>InstallType_Prop = 1</Condition>
<RegistryKey Root="HKLM"
Key="Software\Company\Product\v1.0"
Action="createAndRemoveOnUninstall">
<RegistryValue Type="integer"
Name="OfflineMode"
Value="1"/>
<RegistryValue Type="integer"
Name="Simulator"
Value="0"/>
</RegistryKey>
</Component>
</DirectoryRef>
.
.
.
<Feature Id='Complete'
Level='1'>
<ComponentRef Id='AircraftRegistryEntries'/>
<ComponentRef Id='DesktopRegistryEntries'/>
</Feature>
</Product>
</Wix>
Code Listing 2 - Property and Registry Entry
So as you can see, the radio button is tied to the InstallType_Prop.
What I am trying to accomplish is to install the appropriate registry entry depending on which radio button is selected. I inserted those conditions in the registry components, but they don't seem to be doing anything.
I don't even really have to do it this way - I just need OfflineMode to be set to 1 if Desktop is selected, and set to 0 if Aircraft is selected.
I'm at a loss right now, and I think the solution lies somewhere with a custom action or with the order in which the conditions are evaluated, but I'm not entirely sure.
Any help is appreciated.
IMO the usual way to do this is to group the various components into (say) two features, one per type of system, then the users see the standard feature tree where they choose the appropriate one. In the case of registry entries, you'd have a component (for the registry entry) for each type of install, one would be in one feature, the other in the other.

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>