WiX - fixing more than one property for a pending user action

I have a problem with the WiX installer in contact with pending / immediate user actions. Please excuse my english.

I want to pass some properties entered by the user into a pending user action. I know that for this I need immediate user actions and "CustomActionData". I implement it that way.

Binary:

<Binary Id='myAction' SourceFile='.\TemplateGeneration.CA.dll'/> 

Immediate user action:

 <CustomAction Id='Datenuebergabe' Property='DoSomething' Value='InstalllocVar=[INSTALLLOCATION]'/> 

Pending user action:

 <CustomAction Id='TemplateGenerationInstallKey' BinaryKey ='myAction' DllEntry='DoSomething' Impersonate='no' Execute='deferred' Return='check' HideTarget='yes'/> 

InstallExecuteSequence Function

  <InstallExecuteSequence> <Custom Action="Datenuebergabe" Sequence="1399"/> <Custom Action="TemplateGenerationInstallKey" Before="InstallFinalize"/> </InstallExecuteSequence> 

Property call in deferred user action:

 string somedata = session.CustomActionData["InstalllocVar"]; TemplateEngineCall(somedata+"templates", "install_key_cmd", somedata+"scripts", "install_key.cmd"); 

My problems: If I try to install my program, it will break. With this code, I can only pass one property, but I need to commit more than one.

For information: When I look at the log file, there is a System.Collections.Generic.KeyNotFoundException property during a user action call.

Why is this not working? Well, I need a deferred user action to write to the "program files folder". Because of the necessary rights, a deferred user action is required, and the immediate execution of user actions before the deferred action should help handle the properties. Can this be done?

I hope you understand what my problems are and you can help me.

+6
source share
1 answer

First of all, there is an error in how you transfer data from an immediate user action to a deferred one. The Property name that you use in the immediate custom action must be exactly the same as the Id pending custom action. In your case:

 <!-- immediate CA --> <CustomAction Id='Datenuebergabe' Property='DoSomething' Value='InstalllocVar=[INSTALLLOCATION]'/> <!-- deferred CA --> <CustomAction Id='DoSomething' BinaryKey ='myAction' DllEntry='DoSomething' Impersonate='no' Execute='deferred' Return='check' HideTarget='yes'/> 

This will fix the KeyNotFound exception.

Now back to your question, how to pass more than 1 value.

First, use a delimiter in the near CA ; to pass a collection of values ​​by name:

 <CustomAction Id="SetForDoSomething" Return="check" Property="DoSomething" Value="source=[ArchiveFolder][ARCHIVENAME];target=[WebsiteFolder]"/> 

As you can see, there are two name-value pairs that we pass to the pending CA here, source and target . In a deferred CA, use the following code to extract these values:

 var source = session.CustomActionData["source"]; var target = session.CustomActionData["target"]; 

What is it.

+11
source

Source: https://habr.com/ru/post/956848/


All Articles