[wix-users] Pass variables from one custom action to another

Elena Aralla elena.aralla at gmail.com
Fri Aug 3 07:32:27 PDT 2018


Hi,
thank you for your replay.

This limit is also in Immediate Custom Action, which can read property on session, but can’t modify them and cannot return data to WIX (except for ActionResult) 

So the only solution for me, will be to write data to registry or some ini file, so other Custom Actions can read them.

Could you confirm these statements?
Have a nice day, 
Elena.



> Il giorno 03 ago 2018, alle ore 13:19, harald goci via wix-users <wix-users at lists.wixtoolset.org> ha scritto:
> 
> Hi!
> Deferred Custom Actions cannot return data because of a limitation in
> Installer SDK.
> It seems that WiX creators tried to create a work around which is available
> for C++ only.
> See the posting of Bob Arnson in
> https://stackoverflow.com/questions/27594036/pass-data-between-deferred-custom-action#
> 
> BR,
> Harald Goci
> Senior Software Engineer
> 
> Email: harald.goci at panagenda.com - Web: www.panagenda.com
> Phone: +43 1 890 12 89-44 - Fax: +43 1 890 12 89-15
> 
> (Embedded image moved to file: pic14311.jpg)
> 
> panagenda GmbH - Schreyvogelgasse 3/10 - 1010 Vienna - Austria
> Registered Office: Vienna - HG Wien - FN 293516t - VAT-ID: ATU63362738
> Executive Directors: Florian Vogler (CEO & CTO), Felix Vogler (CFO & COO)
> 
> (Embedded image moved to file: pic25709.jpg)
> 
> The information in this E-Mail is confidential and privileged. It is
> intended solely for the addressee. Access to this E-Mail by anyone else is
> unauthorized. If you are not the intended recipient, any disclosure,
> copying, distribution or any action taken in reliance on it is prohibited
> and will be unlawful. If you receive this message in error, please notify
> the sender immediately and delete all copies of this message.
> 
> 
> 
> 
> From:	Elena Aralla via wix-users <wix-users at lists.wixtoolset.org>
> To:	WiX Toolset Users Mailing List <wix-users at lists.wixtoolset.org>
> Cc:	Elena Aralla <elena.aralla at gmail.com>
> Date:	03.08.2018 12:25
> Subject:	Re: [wix-users] Pass variables from one custom action to
>            another
> Sent by:	"wix-users" <wix-users-bounces at lists.wixtoolset.org>
> 
> 
> 
> 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/
> 
> ____________________________________________________________________
> WiX Toolset Users Mailing List provided by FireGiant http://www.firegiant.com/




More information about the wix-users mailing list