0

The case is, I want to have a checkbox in a dialog. If the checkbox is checked I want to create a file and do some other stuff.

I have a custom action which should using the value of the checkbox-property.

Now I try to pass the checkbox value to my CA-Method but it never receives a value, the variable is present but always empty. I asume the checkbox variable itself is not present at this point, because session.CustomActionData.ToString() shows:

INSTALLFOLDER=C:\Program Files (x86)\WixTesterSetup\;CHECKBOXProperty=

My Dialog is:

<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
  <Fragment>
    <UI Id="UserRegDialogUI">
      <Property Id="Proceed">proceedbtn</Property>
      <Dialog Id="UserRegDialog" Width="400" Height="300" Title="Atled Service Konfiguration">
        <Control Id="headerText" Type="Text" X="65" Y="10" Width="350" Height="40" Transparent="yes" Text="Something to Check" />
        <Control Id="checkboxLabel" Type="Text" X="58" Y="150" Height="14" Width="141" Transparent="yes" Text="Checkbox Text" />
        <Control Id="checkbox" Type="CheckBox" X="60" Y="165" Height="17" Width="120" Property="CHECKBOXProperty" CheckBoxValue="true" />
        <Control Id="proceedButton" Type="PushButton" Text="Weiter" Height="20" Width="43" X="349" Y="266">
          <Publish Event="EndDialog" Value="Return">1</Publish>
        </Control>
        <Control Id="cancelButton" Type="PushButton" Text="Beenden" Height="22" Width="50" X="293" Y="266" Cancel="yes">
          <Publish Event="EndDialog" Value="Exit" />
        </Control>
      </Dialog>
    </UI>
    <InstallUISequence>
      <Show Dialog="UserRegDialog" Before="ExecuteAction" />
    </InstallUISequence>
  </Fragment>
</Wix>

And Product.wsx contains:

<Binary Id="CustomActionBinary" SourceFile="$(var.RegistrationInfoCustomAction.TargetDir)$(var.RegistrationInfoCustomAction.TargetName).CA.dll"/>
    <CustomAction Id="RegistrationInfoCustomAction" BinaryKey="CustomActionBinary" DllEntry="SaveUserInfo" Execute="deferred" Impersonate="no" />
    <CustomAction Id="CustomAction51" Property="RegistrationInfoCustomAction" Value="INSTALLFOLDER=[INSTALLFOLDER];CHECKBOXProperty=[CHECKBOXProperty]" />

    <InstallExecuteSequence>
      <Custom Action="CustomAction51" Before='InstallFinalize' />
      <Custom Action='RegistrationInfoCustomAction' After='CustomAction51'>NOT Installed</Custom>
    </InstallExecuteSequence>

I tried to initialize set the property:

<Property Id="CHECKBOXProperty" Value="true" />

In that case it´s always true even if I uncheck the box. I tried empty value (compiler says the property will be ignored)

May someone tell me a solution?

Felix Arnold
  • 839
  • 7
  • 35

1 Answers1

0

It looks like you're running your custom action with deferred context and I think this is what's causing your problems. Read through Obtaining Context Information for Deferred Execution Custom Actions. If you put your property in CustomActionData it should then be available.

Doc
  • 698
  • 3
  • 16
  • i´ve passed the variable throught the value property of the custom action. `````` – Felix Arnold Nov 25 '19 at 10:03
  • And...if you write this property out to the log using your custom action is it empty at that time? The log is going to be your salvation with diagnosing these kinds of problems. – Doc Nov 26 '19 at 01:29
  • if I debug the action the variable is string.empty. Like undefined – Felix Arnold Nov 26 '19 at 16:07
  • That means the property did not exist at the time you stepped into it. In Windows installer if you set a property to a null value it effectively deletes it. But my suspicion is that you still don't have the property available outside of the installer context since it is deferred. – Doc Nov 26 '19 at 19:47
  • So how do I use a variable from a Dialog? – Felix Arnold Nov 27 '19 at 10:13
  • You can create a text label and just populate it with [PropertyName]. If you're in a custom action it'll depend on the language of the custom action. Usually session.property("PropertyName") – Doc Nov 27 '19 at 15:41