A.Pissicat
A.Pissicat

Reputation: 3265

Add more than one checkbox when install with Wix is over

I have an setup for my C# application. At the end of setup I added a checkbox proposing to launch application. It works good. But i'm unable to add a second checkbox proposing to launch an optional installer.

There is my code:

<?xml version="1.0" encoding="UTF-8"?>
<?define compagny = "myCompagny"?>
<?define product = "myProduct"?>
<?define version = "!(bind.FileVersion.MyProject.exe)"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
     xmlns:util="http://schemas.microsoft.com/wix/UtilExtension">
  <Product Id="*"
           Name="$(var.product)"
           Language="1033"
           Version="$(var.version)"
           Manufacturer="$(var.compagny)"
           UpgradeCode="PUT-GUID-HERE">
    <Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine"/>
    <Icon Id="icone.ico" SourceFile="$(var.MyProject.ProjectDir)\Images\icone-VR.ico"/>
    <Property Id="ARPPRODUCTICON" Value="icon.ico"/>
    <MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed."/>
    <Media Id="1" Cabinet="MyProject.cab" EmbedCab="yes"/>

    <Feature Id="ProductFeature" Title="$(var.product)" Level="1">
      <ComponentGroupRef Id="ProductComponents"/>
      <ComponentRef Id ="ApplicationShortcut"/>
      <ComponentRef Id ="ApplicationShortcutDesk"/>
    </Feature>

    <WixVariable Id="WixUILicenseRtf"
                 Value="..\license.rtf"/>
    <WixVariable Id="WixUIBannerBmp"
                 Value=".\Resources\WixUIBannerBmp.bmp"/>
    <WixVariable Id="WixUIDialogBmp"
                 Value=".\Resources\WixUIDialogBmp.bmp"/>

    <Property Id="WIXUI_EXITDIALOGOPTIONALCHECKBOXTEXT" Value="Launch $(var.product)" />
    <Property Id="WIXUI_EXITDIALOGOPTIONALTEXT" Value="Warning. If you don't have optionnal package, consider to install it."/>

    <Property Id="WixShellExecTarget" Value="[#MyProject.exe]" />
    <CustomAction Id="LaunchApplication" BinaryKey="WixCA" DllEntry="WixShellExec" Impersonate="yes" />

    <UI>
      <UIRef Id="WixUI_Minimal"/>
      <Publish Dialog="ExitDialog"
               Control="Finish" 
               Event="DoAction" 
               Value="LaunchApplication">WIXUI_EXITDIALOGOPTIONALCHECKBOX = 1 and NOT Installed</Publish>
    </UI>
  </Product>

  [...]
 </Wix>

How can I add another CheckBox to launch ./Resources.myOptionalPackage.exe ?

If I can't add another checkbox, can I add a new dialog page used to install the feature ?

Upvotes: 4

Views: 1797

Answers (1)

Mischo5500
Mischo5500

Reputation: 796

You must create own edited UI with custom dialog.

1.First go to official GIT repository and copy files WixUI_Minimal.wxs and ExitDialog.wxs , or copy whole repository and find files locally. Create own copies of this files to you project/Solution and rename them for example to WixUI_Custom.wxs and MyExitDialog.wxs .

Replace content of new files too, for WixUI_Minimal.wxs replace

<UI Id="WixUI_Minimal"> to <UI Id="WixUI_Custom">,

for ExitDialog.wxs replace

<Dialog Id="ExitDialog" Width="370" Height="270" Title="!(loc.ExitDialog_Title)"> to <Dialog Id="MyExitDialog" Width="370" Height="270" Title="!(loc.ExitDialog_Title)">

and both

<Show Dialog="ExitDialog" OnExit="success" Overridable="yes" /> to <Show Dialog="MyExitDialog" OnExit="success" Overridable="yes" />

2.Change <UIRef Id="WixUI_Minimal"/> in your Product to <UIRef Id="WixUI_Custom"/>

3.Now you installer should open with exact UI as before, but from your classes

4.Open WixUI_Custom and change

<Publish Dialog="ExitDialog" Control="Finish" Event="EndDialog" Value="Return" Order="999"> to <Publish Dialog="ExitDialog" Control="Finish" Event="EndDialog" Value="Return" Order="999">

so UI will open our new Dialog.

5.Open MyExitDialog.wxs and add new Control block, as it is already present

<Control Id="OptionalCheckBox" Type="CheckBox" X="135" Y="190" Width="220" Height="40" Hidden="yes" Property="WIXUI_EXITDIALOGOPTIONALCHECKBOX" CheckBoxValue="1" Text="[WIXUI_EXITDIALOGOPTIONALCHECKBOXTEXT]">
  <Condition Action="show">
    WIXUI_EXITDIALOGOPTIONALCHECKBOXTEXT AND NOT Installed
  </Condition>
</Control>

Change identificator Id to anything, X,Y for new position in dialog, Property for new property, in which will be checkbox value stored and Text for new property, in which will be displayed text stored. Place Text property to Condition too, so display will depend on text property set, as in existing checkbox.

<Control Id="SecondCheckBox" Type="CheckBox" X="135" Y="220" Width="220" Height="40" Hidden="yes" Property="WIXUI_SECONDCHECKBOXVALUE" CheckBoxValue="1" Text="[WIXUI_EXITDIALOGSECONDCHECKBOXTEXT]">
  <Condition Action="show">
    WIXUI_EXITDIALOGSECONDCHECKBOXTEXT AND NOT Installed
  </Condition>
</Control>

6.Now you can do the same things with new Checkbox as with existing using new properties defined in new Control.

Upvotes: 5

Related Questions