My MSI installation needs to be two-phase. In the first I collect data from user, and in the second one I want to run the actual installation using the collected values from the 1st phase. The 2nd phase needs to be run in elevated context.
I found on the Web that the only way to pass values to the elevated deffered action is to set properties. In MSDN article (and also on some examples over the web) it is said that I need to
- set property [named the same as the "primary key" of the deffered action] - with the value to be passed to the deffered action. Specifically, the value can be in the form of key=value string format, repeated and semicolon delimited.
- fetch values in the deffered action using the indexer (passing the keys).
I start off with the actions definition:
project.Actions = new []
{
new ManagedAction(InstallerActions.LiveBankInstallPrepare, Return.check, When.After, Step.InstallExecute,
Condition.Always, Sequence.InstallExecuteSequence)
{
ActionAssembly = "%this%",
Name = "Preparing installation",
},
new ElevatedManagedAction(InstallerActions.LiveBankInstallExecute, Return.check, When.After, Step.InstallExecute,
Condition.Always, Sequence.InstallExecuteSequence)
{
ActionAssembly = "%this%",
Name = "Executing installation",
Id = "ABCD"
},
};
Having collected the data in the 1st action I store it in the property named the same as the ID of the deffered action
propertyDict = BuildSemicolonSeparatedDict();
session["ABCD"] = propertyDict;
//at runtime propertyDict is e.g. execMode=InstallForced; timeout=5
The question that I have is:
What am I doing wrong, that I can not see in the deffered action the propertyDict assigned in the first step (action).
var execMode = session.CustomActionData["execMode"];
//key not found in the dictionary, however propertyDict built in the first action contains it.
I guess I must be passing the value wrong, as when I statically set the action parameters with UsesProperties property, I can see the key-value pairs in the deffered action.