I'm trying to create a custom action with "Value" attribute, I want to pass parameters to the C# code (the TARGETDIR and the version).
However, I get an error stating that DLLENtry and Value cannot coexist. But the custom action without dllentry is invalid.
This is the code:
<CustomAction Id="SetMAWPrefferences"
Value="InstallDir=[TARGETDIR];Version=2.0.0.1"
Return="check"
Execute="commit"
BinaryKey="ImportExportBinary"
/>
And for it I get this error:
Error 9 ICE68: Invalid custom action type for action 'SetMAWPrefferences'.
Any ideas how to do it?
Note, you're using Value
attribute in the wrong way:
...this attribute must be used with the Property attribute to set the property...Source
Based on the Creating WiX Custom Actions in C# and Passing Parameters article you should:
Create properties with desired values:
<Property Id="InstallDir" Value="someDefaultValue" />
<Property Id="Version" Value="2.0.0.1" />
Create custom action to set the InstallDir
property:
<CustomAction Id="SetDirProp" Property="InstallDir" Value="[TARGETDIR]" />
Create custom action:
<CustomAction Id="SetMAWPrefferences"
Return="check"
Execute="commit"
BinaryKey="ImportExportBinary"
DllEntry="YourCustomAction" />
Schedule custom actions for execution during installation process:
<InstallExecuteSequence>
<Custom Action="SetDirProp" After="CostFinalize" />
<Custom Action="SetMAWPreferences" ... />
...
</InstallExecuteSequence>
Access those properties from your custom action as follows:
[CustomAction]
public static ActionResult YourCustomAction(Session session)
{
// session["InstallDir"]
// session["Version"]
}