How are properties set on CustomActionData to be retrieved by a deferred custom action?
How are properties set on CustomActionData to be retrieved by a deferred custom action?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Deferred custom actions can not directly access installer properties (reference). In fact, only
CustomActionDatapropertyand other methods and properties listed here are available on the session object.
Therefore, for a deferred custom action to retrieve a property such as the
INSTALLLOCATION, you have to use a type 51 custom action — i.e. a set-property custom action — to pass that information along and you’ll consume the data from the CustomAction’s C# code throughsession.CustomActionData. (see reference & reference)Below is an example of a type 51 custom action (
CustomAction1) that will set a property that can be retrieved inCustomAction2.Notice that
Propertyattribute name isCustomAction2. This is important. The Property attribute’s value of the type 51 action must be equal/identical to the name of the custom action that is consumingCustomActionData. (see reference)Notice the name
SomeCustomActionDataKeyin theValueattribute key/value pair? In your C# code in the consuming custom action (CustomAction2), you’ll look-up that property fromCustomActionDataby using the following expression:The key that you use to retrieve the value from
CustomActionDatais NOT the value inPropertyattribute of the type 51 custom action, but the key from thekey=valuepair in theValueattribute. (Important takeaway:CustomActionDatais populated by setting an installer property that has the same name as the Id of the consuming custom action, butCustomActionDatakeys are NOT installer properties.) (see reference)In our scenario the consuming custom action is a deferred custom action defined somewhat like the below:
Configuring the InstallExecuteSequence
Of course, the consuming custom action (
CustomAction2) must run after the type 51 custom action (CustomAction1). So you’ll have to schedule them like this: