How to create a variable / property in Wix and pass to it the value of using C#?
I am writing project installer and encountered a problem related to the transfer of value from C# ([CustomAction] Wix and Bootstrapper) to Wix Toolset 3.10. Both solutions do not work.
Solution 1: Using Wix Bootstrapper:
Bootstrapper.Engine.StringVariables["MyVariable"] = "test";
Solution 2: Using the Custom Actions: I create Bundle.wxs variable:
<Variable Name="MyVariable" Type="string" Value="" />
I set a property in the MSI Property, which should be the value of the variable "MyVariable":
<MsiProperty Name=" MYVARIABLE" Value="[MyVariable]" />
I create Product.wxs property:
<Property Id="MyVariable" Value="abcXYZ123" />
I create Product.wxs Custom Actions in which we set the property:
<CustomAction Id="MyVariable" Property="MyVariable" Value="[MyVariable]" />
I create a Custom Action in Product.wxs:
<CustomAction Id="Prefferences"
BinaryKey="MyCustomAction"
DllEntry="MySimpleAction"
Execute="immediate"
Return="ignore" />
Performing during the installation process:
<InstallExecuteSequence>
<Custom Action="Prefferences" After="InstallFiles">
<![CDATA[Not Installed and Not Reinstall]]>
</Custom>
</InstallExecuteSequence>
I create in class Custom Action.cs access to these properties:
[CustomAction]
public static ActionResult MySimpleAction(Session session)
{
session["MyVariable"] = "Test przesłania parametru!";
return ActionResult.Success;
}
Both solution does not convey the text of the C # code to Wix.