How do I publish a CustomAction when Dialog is showing - wix

I have following Fragment to define my CustomActions (actually 2 methods in my CA-project)
<Fragment>
<Binary Id="FooAssembly"
SourceFile="Foo.CA.dll" />
<CustomAction Id="Action1"
BinaryKey="FooAssembly"
DllEntry="Action1" />
<CustomAction Id="Action2"
BinaryKey="FooAssembly"
DllEntry="Action2" />
</Fragment>
My Action1 looks like this:
[Microsoft.Deployment.WindowsInstaller.CustomAction]
public static ActionResult Action1(Microsoft.Deployment.WindowsInstaller.Session session)
{
session["value1"] = "some value";
session["value2"] = "some value";
return ActionResult.Success;
}
Now I need to run this CustomAction when my dialog is showing and bind the value value1 to a Edit-control like so:
<Dialog Id="FooDlg">
<Control Id="FooEdit"
Type="Edit"
Text="[value1]"
Property="value1"
Disabled="yes" />
</Dialog>
My InstallUISequence looks like this
<InstallUISequence>
<Show Dialog="FooDlg"
After="CostFinalize" />
</InstallUISequence>
I am using an Edit-control here, because I need some border - which Text is missing - and therefore I need to have the attribute Property filled.
How can I achieve this?

I have solved this by adapting my InstallUISequence like
<InstallUISequence>
<Custom Action="Action1"
After="CostFinalize" />
<Show Dialog="FooDlg"
After="Action1" />
</InstallUISequence>

Related

WIX customAction Checkbox

I am try to use Checkbox with this sample from WIX
nothing happened when I try to use the Checkbox
Regards
<Binary Id="StringTransfer" SourceFile="$(var.SolutionDir)CustomAction2\bin\Release\CustomAction2.CA.dll" />
<CustomAction
Id="INSTALLSETTINGS"
BinaryKey="StringTransfer"
DllEntry="CustomAction1"
Execute="deferred"
Impersonate="no"
Return="check"
/>
<InstallExecuteSequence>
<Custom Action="INSTALLSETTINGS" After="InstallInitialize">
CHECKBOXINSTALLSETTINGS=1
</Custom>
</InstallExecuteSequence>
<Control Id="test" Type="CheckBox" Width="125" Height="26" X="26" Y="124" Text="My text" Property="CHECKBOXINSTALLSETTINGS" CheckBoxValue="1" />
<Property Id="CHECKBOXINSTALLSETTINGS" Value="1"/>
<CustomAction()>
Public Shared Function CustomAction1(ByVal session As Session) As ActionResult
My.Computer.Registry.SetValue("HKEY_CURRENT_USER\SOFTWARE\VB and VBA Program Settings\Test", "mintext", "0")
session.Log("Begin CustomAction1")
Return ActionResult.Success
End Function

WIX pass checkbox value to custom action

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?
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.

WiX - altering text in ExitDialog depending on result of an action after InstallFinalize

I would like to alter text in ExitDialog depending on result of an immediate action, executed after InstallFinalize. I have tried to do this with the use of property to be set by the action (ISSUCCEEDED in the snippet below), but as I understand it, installer lost this property after the transition from server to client phase. If so, how this could be done?
<!-- The MyAction sets the property ISSUCCEEDED -->
<CustomAction Id="MyAction" BinaryKey="..." DllEntry="..."/>
<InstallExecuteSequence>
<Custom Action="MyAction" After="InstallFinalize">...</Custom>
</InstallExecuteSequence>
<UI>
<Dialog Id="MyExitDialog" ...>
...
<!-- ISSUCCEEDED is lost by now -->
<Control Id="C1" Type="Text" Hidden="yes" Text="!(loc.Text1)"...>
<Condition Action="show">ISSUCCEEDED</Condition>
</Control>
<Control Id="C2" Type="Text" Hidden="yes" Text="!(loc.Text2)"...>
<Condition Action="show">NOT ISSUCCEEDED</Condition>
</Control>
...
</Dialog>
</UI>

properties attached to UI don't get changed

In my WiX install package I define a property, then define a textbox that uses this property, then pass this property to my custom action. But inside of the custom action I find out that the property has it's default value, not the one I've specified in the textbox. How can I fix that?
<Property Id="DataSource" Value="."/>
<Control Id="DataSourceText" Type="Edit" Text="." Height="17" Width="150" X="200" Y="18" Property="DataSource"/>
then later in the code
<CustomAction Id="SetCustomActionDataValue" Return="check" Property="CreateDatabase" Value="DataSource=[DataSource]" />
<CustomAction Id="CreateDatabase" BinaryKey="Binary1" DllEntry="CreateDatabase" Execute="deferred" Return="ignore"/>
<InstallExecuteSequence>
<Custom Action='SetCustomActionDataValue' After="InstallFiles"/>
<Custom Action='CreateDatabase' After="SetCustomActionDataValue">NOT Installed AND NOT PATCH</Custom>
</InstallExecuteSequence>
Any properties that you intend to modify in the UI sequence and use in the Execute sequence must be Secure Custom Properties.

WiX: No InstallUISequence table being created in MSI

I have a WiX file that includes this snippet:
<CustomAction Id="DownloadCache" FileKey="CACHEDOWNLOADER.EXE" ExeCommand="/v" Execute="deferred" Return="ignore"/>
<UI>
<Dialog Id="ExitDialog" Title="Product Installer" Height="60" Width="250">
...
</Dialog>
<Dialog Id="FatalErrorDialog" Title="Product Installer" Height="60" Width="250">
...
</Dialog>
<TextStyle Id="DefaultFont" FaceName="Arial" Size="10" />
<Property Id="DefaultUIFont" Value="DefaultFont" />
<InstallUISequence>
<Custom Action="DownloadCache" After="ExecuteAction">(NOT Installed) AND (Not REMOVE)</Custom>
<Show Dialog="ExitDialog" OnExit="success" />
<Show Dialog="FatalErrorDialog" OnExit="error" />
</InstallUISequence>
</UI>
<InstallExecuteSequence>
<Custom Action="DownloadCache" After="WriteRegistryValues">(NOT Installed) AND (Not REMOVE)</Custom>
</InstallExecuteSequence>
The issue is, the resulting .MSI does NOT contain an InstallUISequence table.
I went through the tutorial Events and Actions and the above seems correct. I'm definitely missing something here. How can I fix it?
There must be more than meets the eye here. Even the simplest fragment below will generate an InstallUISequence table with the bare minimum actions of ValidateProductID, CostInitialize, FileCost, CostFinalize and ExecuteAction. No actual UI elements per se, but that's another issue.... (Are Dialogs Optional Now??)
<Wix...>
<Product...>
<Package.../>
</Product>
</Wix>