We have developed a pretty comprehensive wix installer msi package, which includes some 10+ c# custom actions.
My problem is that I have yet to figure out how to programmatically "set" a property.
Basically what I want to do is to parse an existing property into a new property.
This parsing would be nice to do in c#, but could also be done in RegEx, JavaScript or w/e.
However I am unable to do this from my c# custom actions ("Cannot access session details from a non-immediate custom action") and as far as I can read I can only change a property from a type 51 custom action. However a type 51 cannot use my c# custom actions. So its catch 22.
Can anyone give give me an example on how to perform the following in wix: Perform a regular expression/string manipulation using the value of one property and setting another with the result.
It seems obvious to me that this should be possible, but after a lot of searching I am still in the dark.
Any help would be appreciated.
Edit #1: After 3 years of working with wix, I still feel like an amateur, but here goes: I thought the only way to send properties and work with them in a custom action was this pattern:
<CustomAction Id="CA.SetCreateMessageQueueProperty"
Property="CA.CreateMessageQueue"
Value="MsmqData=.\Private$\[MYAPPLICATIONNAME]/ObservationReportingService.svc,Observation delivery queue"
Return="check"/>
<CustomAction Id="CA.CreateMessageQueue"
BinaryKey="BI.CA"
DllEntry="CreateMessageQueue"
Execute="deferred"
Return="check"
Impersonate="no"/>
<InstallExecuteSequence>
<Custom Action="CA.SetCreateMessageQueueProperty"
After="InstallFiles"/>
<Custom Action="CA.CreateMessageQueue" After="CA.SetCreateMessageQueueProperty">
<![CDATA[((&FE.Afs=3) AND NOT (!FE.Afs=3))]]>
</Custom>
</InstallExecuteSequence>
In the custom action c# assembly:
[CustomAction]
public static ActionResult CreateMessageQueue(Session session)
{
return session.DoCustomAction("CreateMessageQueue",
() =>
{
string msmqData = session.ExtractString("MsmqData");
//create actual message queue
}
}
});
}
internal static ActionResult DoCustomAction(this Session session, string name, Action action)
{
session.Log("Begin " + name);
session.Log("session.CustomActionData.Count:" + session.CustomActionData.Count);
try
{
action.Invoke();
}
catch (Exception ex)
{
session.Log(string.Format("Exception: {0}\nInner Exception: {1}", ex, ex.InnerException));
return ActionResult.Failure;
}
return ActionResult.Success;
}