Wix Custom Action - session empty and error on deferred action

前端 未结 1 774
伪装坚强ぢ
伪装坚强ぢ 2020-12-07 04:34

I am using Wix 3.11.1 with VS2017 Extension. I set a property from a control on a custom Dialogue and then try to execute an immediate custom action. When I try to read the

相关标签:
1条回答
  • 2020-12-07 05:12

    UPDATE: It is late, I didn't see this on first sight, but only immediate mode custom actions can be run from the setup GUI. Make a new, immediate mode custom action to set a value to your PUBLIC property CONN, and then set the value of CONN via a type 51 custom action to be assigned to the Id of the deferred mode custom action - as described below.


    SecureCustomProperties: Add the property you specify to SecureCustomProperties by setting the Secure="yes" attribute:

    <Property Id="MYPROPERTY" Secure="yes">Send this text to deferred mode</Property>
    

    Name Match: the property name you assign the value to must match the deferred mode custom action Id. Looks OK in your source.

    More Technical: the Property attribute's value of the type 51 action must be identical to the Id of the custom action that is consuming CustomActionData:

    <!-- Declare property with value -->
    <Property Id="MYPROPERTY" Secure="yes">Send this text to deferred mode</Property>
    
    <!-- Type 51 CA: Send value of MYPROPERTY to the deferred mode CA named MyAction -->
    <CustomAction Id="MyAction.SetProperty" Return="check" Property="MyAction" Value="[MYPROPERTY]" />
    
    <!-- The deferred mode custom action -->
    <CustomAction Id="MyAction" Return="check" Execute="deferred" BinaryKey="CAs" DllEntry="MyAction" />
    
    <!-- ... -->
    
    <!-- Inserting the CAs in sequence -->
    <InstallExecuteSequence>
        <Custom Action="MyAction.SetProperty" After="InstallInitialize" />
        <Custom Action="MyAction" Before="InstallFinalize" />
    </InstallExecuteSequence>
    

    Here are some resources:

    • How to pass CustomActionData to a CustomAction using WiX?
    • https://www.firegiant.com/wix/tutorial/events-and-actions/at-a-later-stage/
    • How to access installer properties from deferred custom actions
    • Accessing or Setting Windows Installer Properties Through Deferred, Commit, and Rollback Custom Actions
    • Getting CustomActionData in deferred custom action

    Just for debugging reference. And you can use: string data = session["CustomActionData"];


    Tell you what, let me slide in the code to test using VBScript so you can use message boxes. Should not be necessary, just in case you have a debugging issue:

    VBScript "Simple.vbs" (save as file):

    MsgBox Session.Property("CustomActionData")
    

    WiX markup change:

    <Binary Id='Simple.vbs' SourceFile='Simple.vbs' />
    <CustomAction Id="MyAction" Return="check" Execute="deferred" BinaryKey="Simple.vbs" VBScriptCall='' />
    

    Just in case that is easier. Recommend you use VBScript for debugging only. I like VBScript to get a "heartbeat" when I want to eliminate all other error sources.

    0 讨论(0)
提交回复
热议问题