[wix-users] Pass variables from one custom action to another
Edwin Castro
egcastr at gmail.com
Fri Aug 3 07:15:37 PDT 2018
In the Windows Installer information flows in one direction only as it
concerns deferred actions.
Immediate mode actions have full access to MSI tables and properties. An
immediate mode action could read a property, make modifications, and write
the result in the same property or a new property. Immediate mode actions
cannot change system state.
Deferred actions effectively have access to a special CustomActionData
property *only*! No access to tables or other properties. In reality they
do have access to a couple more things but in practice it you only use
CustomActionData. Deferred actions cannot write properties but they can
change system state.
In essence, immediate mode actions decide *what* to do and deferred actions
know *how* to do it.
As you already know, immediate mode actions can set CustomActionData for a
given deferred action by writing a property with the same Id as the
deferred action but they can also write any property they want (excluding
special read-only "system" properties).
Deferred actions cannot write properties so they cannot communicate with
other actions.
--
Edwin G. Castro
On Fri, Aug 3, 2018, 03:25 Elena Aralla via wix-users <
wix-users at lists.wixtoolset.org> wrote:
> Hi,
>
> I tried without success!
>
> I can pass data of CustomAction1 to CustomAction2 -> OK; I can change the
> value of session.CustomActionData["SomeCustomActionDataKey”] from 1 to 2!
> (see log at the end of this email)
>
> How can I pass SomeCustomActionDataKey, defined in CustomAction1 and
> changed in CustomAction2 to CustomAction3 or CustomAction4 too?
>
> This is my code:
>
> Product.wxs:
> =======================================
>
> <Property Id="MyVar" Value="1" />
>
> <CustomAction Id="CustomAction1"
> Property="CustomAction2"
> Value="SomeCustomActionDataKey=[MyVar]"/>
>
> <Binary Id="CustomActionABin"
> SourceFile="$(var.CustomActionA.TargetDir)$(var.CustomActionA.TargetName).CA.dll"
> />
> <CustomAction Id="CustomAction2"
> BinaryKey="CustomActionABin"
> DllEntry="CustomAction1"
> Execute="deferred"
> Return="check"
> HideTarget="no" />
>
>
> <CustomAction Id="CustomAction3"
> Property="CustomAction4"
> Value="SomeCustomActionDataKey=WHAT VALUE THERE??"/>
>
> <!-- custom action - riferimento alla dll -->
> <Binary Id="CustomActionBBin"
> SourceFile="$(var.CustomActionB.TargetDir)$(var.CustomActionB.TargetName).CA.dll"
> />
> <CustomAction Id="CustomAction4"
> BinaryKey="CustomActionBBin"
> DllEntry="CustomAction1"
> Execute="deferred"
> Return="check"
> HideTarget="no" />
>
>
>
> <InstallExecuteSequence>
> <Custom Action="CustomAction1" Before="CustomAction2" />
> <Custom Action="CustomAction2" Before="CustomAction3" />
> <Custom Action="CustomAction3" Before="CustomAction4" />
> <Custom Action="CustomAction4" After="InstallInitialize" />
> </InstallExecuteSequence>
>
>
>
> CustomActionA
> =======================================
>
> using System;
> using System.Collections.Generic;
> using System.Text;
> using Microsoft.Deployment.WindowsInstaller;
>
> namespace CustomActionA
> {
> public class CustomActions
> {
> [CustomAction]
> public static ActionResult CustomAction1(Session session)
> {
> session.Log("Begin CustomAction1");
>
>
> session.Log("session.CustomActionData[\"SomeCustomActionDataKey\"]={0}",
> session.CustomActionData["SomeCustomActionDataKey"]);
>
> session.CustomActionData["SomeCustomActionDataKey"] = "2";
>
>
> session.Log("session.CustomActionData[\"SomeCustomActionDataKey\"]={0}",
> session.CustomActionData["SomeCustomActionDataKey"]);
>
> return ActionResult.Success;
> }
> }
> }
>
>
> CustomActionB
> =======================================
>
> using System;
> using System.Collections.Generic;
> using System.Text;
> using Microsoft.Deployment.WindowsInstaller;
>
> namespace CustomActionB
> {
> public class CustomActions
> {
> [CustomAction]
> public static ActionResult CustomAction1(Session session)
> {
> session.Log("Begin CustomAction1");
>
> // this should have value=2!!
>
> session.Log("session.CustomActionData[\"SomeCustomActionDataKey\"]={0}",
> session.CustomActionData["SomeCustomActionDataKey"]);
>
> session.CustomActionData["SomeCustomActionDataKey"] = "3";
>
>
> session.Log("session.CustomActionData[\"SomeCustomActionDataKey\"]={0}",
> session.CustomActionData["SomeCustomActionDataKey"]);
>
> return ActionResult.Success;
> }
> }
> }
>
>
> LOG:
>
>
> Begin CustomAction1A
> MSI (s) (CC!88) [11:55:49:619]: Closing MSIHANDLE (162) of type 790531 for
> thread 17800
> MSI (s) (CC!88) [11:55:49:623]: Creating MSIHANDLE (163) of type 790531
> for thread 17800
> session.CustomActionData=1
> MSI (s) (CC!88) [11:55:49:624]: Closing MSIHANDLE (163) of type 790531 for
> thread 17800
> MSI (s) (CC!88) [11:55:49:627]: Creating MSIHANDLE (164) of type 790531
> for thread 17800
> session.CustomActionData=2
> MSI (s) (CC!88) [11:55:49:628]: Closing MSIHANDLE (164) of type 790531 for
> thread 17800
> MSI (s) (CC:04) [11:55:49:641]: Closing MSIHANDLE (158) of type 790536 for
> thread 8404
> MSI (s) (CC:D4) [11:55:49:643]: Executing op:
> ActionStart(Name=CustomAction4,,)
> MSI (s) (CC:D4) [11:55:49:645]: Executing op:
> CustomActionSchedule(Action=CustomAction4,ActionType=1025,Source=BinaryData,Target=CustomAction1,CustomActionData=SomeCustomActionDataKey=)
> MSI (s) (CC:D4) [11:55:49:647]: Creating MSIHANDLE (165) of type 790536
> for thread 8404
> MSI (s) (CC:EC) [11:55:49:649]: Invoking remote custom action. DLL:
> C:\WINDOWS\Installer\MSIF093.tmp, Entrypoint: CustomAction1
> MSI (s) (CC!B4) [11:55:49:718]: Creating MSIHANDLE (166) of type 790531
> for thread 21428
> SFXCA: Extracting custom action to temporary directory:
> C:\Users\BugFree\AppData\Local\Temp\MSIF093.tmp-\
> MSI (s) (CC!B4) [11:55:49:722]: Closing MSIHANDLE (166) of type 790531 for
> thread 21428
> MSI (s) (CC!B4) [11:55:49:772]: Creating MSIHANDLE (167) of type 790531
> for thread 21428
> SFXCA: Binding to CLR version v4.0.30319
> MSI (s) (CC!B4) [11:55:49:775]: Closing MSIHANDLE (167) of type 790531 for
> thread 21428
> MSI (s) (CC!B4) [11:55:49:814]: Creating MSIHANDLE (168) of type 790531
> for thread 21428
> Calling custom action
> CustomActionB!CustomActionB.CustomActions.CustomAction1
> MSI (s) (CC!B4) [11:55:49:823]: Closing MSIHANDLE (168) of type 790531 for
> thread 21428
> MSI (s) (CC!B4) [11:55:49:829]: Creating MSIHANDLE (169) of type 790531
> for thread 21428
> Begin CustomAction1B
> MSI (s) (CC!B4) [11:55:49:832]: Closing MSIHANDLE (169) of type 790531 for
> thread 21428
> MSI (s) (CC!B4) [11:55:49:837]: Creating MSIHANDLE (170) of type 790531
> for thread 21428
> session.CustomActionData=
> MSI (s) (CC!B4) [11:55:49:838]: Closing MSIHANDLE (170) of type 790531 for
> thread 21428
> MSI (s) (CC!B4) [11:55:49:841]: Creating MSIHANDLE (171) of type 790531
> for thread 21428
> session.CustomActionData=3
>
>
>
>
>
>
>
>
>
> > Il giorno 02 ago 2018, alle ore 12:01, Fyodor Koryazhkin via wix-users <
> wix-users at lists.wixtoolset.org> ha scritto:
> >
> > Hi,
> > The best way to pass data from one CA to another is to use properties. If
> > your CA that consumes properties is deferred then all properties can be
> > passed as a string in one property that has ID as your deferred action;
> and
> > in your deferred action you retrieve that string reading CustomActionData
> > property. If your properties hold sensitive data you mark them as hidden
> > and you add attribute
> > msidbCustomActionTypeHideTargetto your CA
> >
> > On Thu, Aug 2, 2018 at 12:48 PM Elena Aralla via wix-users <
> > wix-users at lists.wixtoolset.org> wrote:
> >
> >>
> >> Hi,
> >>
> >> I’m using the registry to exchange data between custom actions.
> >>
> >> For example, I have a custom action that determines the directory where
> to
> >> install the program depending on my business rules.
> >>
> >> this CA writes the resulting value in the registry the custom action
> that
> >> installs the database (I’m using SQLCE) reads from the registry the
> >> directory and uses it to decide where to save the db.
> >>
> >> It works!
> >>
> >> Is there any drawback or a better way to do this?
> >>
> >> Thank you,
> >> Elena.
> >>
> >> ____________________________________________________________________
> >> WiX Toolset Users Mailing List provided by FireGiant
> >> http://www.firegiant.com/
> >
> >
> >
> > --
> > Regards,
> > Fyodor Koryazhkin..
> >
> > ____________________________________________________________________
> > WiX Toolset Users Mailing List provided by FireGiant
> http://www.firegiant.com/
>
>
> ____________________________________________________________________
> WiX Toolset Users Mailing List provided by FireGiant
> http://www.firegiant.com/
More information about the wix-users
mailing list