Pending user actions cannot directly access the properties of the installer ( link ). In fact, only the CustomActionData property
session.CustomActionData
and the other methods and properties listed here are available for the session object.
Therefore, for a deferred custom action to retrieve a property, such as INSTALLLOCATION , you must use a custom action of type 51, that is, the set-property custom action, to pass this information, and you will use the data from CustomAction C # code through session.CustomActionData . (see link and link )
The following is an example of a custom action of type 51 ( CustomAction1 ), in which the property that can be obtained in CustomAction2 will be set.
<CustomAction Id="CustomAction1" Property="CustomAction2" Value="SomeCustomActionDataKey=[INSTALLLOCATION]" />
Notice the attribute name is Property CustomAction2 . It is important. The value of the attribute of the action property of type 51 must be equal to / identical to the name of the custom action that CustomActionData consumes. (see link )
Pay attention to the name SomeCustomActionDataKey in the key / value pairs of the Value attribute? In C # code, in a custom user action ( CustomAction2 ), you will see this property from CustomActionData using the following expression:
string somedata = session.CustomActionData["SomeCustomActionDataKey"];
The key that you use to retrieve the value from CustomActionData is NOT the value of the Property attribute for a custom action of type 51, but the key from the key=value pair in the Value attribute. (Important takeaway: CustomActionData populated by setting the installer property with the same name as the user action ID, but CustomActionData are not settings for the installation.) (See link )
In our scenario, the user consumption action is a deferred user action, defined as below:
<Binary Id="SomeIdForYourBinary" SourceFile="SomePathToYourDll" /> <CustomAction Id="CustomAction2" BinaryKey="SomeIdForYourBinary" DllEntry="YourCustomActionMethodName" Execute="deferred" Return="check" HideTarget="no" />
Configuring InstallExecuteSequence
Of course, the user action of the user ( CustomAction2 ) should be triggered after the user action of type 51 ( CustomAction1 ). Therefore, you will have to plan them as follows:
<InstallExecuteSequence> <Custom Action="CustomAction1" Before="CustomAction2" /> <Custom Action="CustomAction2" After="[SomeInstallerAction]" /> </InstallExecuteSequence>