During the install interview I collect information about the database connection and this information has to be added to an xml file which is added during install. I could do this using the XmlConfig or XmlFile elements, but unfortunately some of the information have to be encrypted before added to the file. This is, of course, not possible using the MSI or WiX elements, so I have to use a CA which then handles the encryption.
The Xml is used by a windows service installed and started during the install, so I have to modify the file AFTER the files have been installed, but before the service is started. I struggled with this for a while, it was easy enough to find the exact spot to call the CA, however it seems (according to the log file) that the MSI makes two passes, so to speak. And the CA fired during the first pass where the installer is simply figuring out what to do, as far as I can figure. So, I figured out that I need to delay the execution of the CA to the second pass, but how to do that? I have tried with Execute="commit" and Execute="Deferred" like this: <CustomAction Id="AddXmlConfig" BinaryKey="XmlConfig" DllEntry="AddXml" Execute="commit"/> <InstallExecuteSequence> <RemoveExistingProducts After="InstallInitialize"/> <LaunchConditions After="AppSearch"/> <Custom Action="AddXmlConfig" After="InstallServices" >SERVERINSTALL</Custom> </InstallExecuteSequence> But this results in this exception thrown: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> Microsoft.Deployment.WindowsInstaller.InstallerException: Cannot access session details from a non-immediate custom action What does this mean? Why can I not access session details during commit or deferred, and how do I access the properties then? My CA looks like this, somewhat shortened though: [CustomAction] public static ActionResult AddXml(Session session) { string xmlDoc = Path.Combine(session["INSTALLDIR"], "configuration.xml"); // Exact data from Session properties and encrypt where necessary XmlDocument doc = new XmlDocument(); if (File.Exists(xmlDoc)) { doc.Load(xmlDoc); // Add nodes and attributes to the xml document doc.Save(xmlDoc); return ActionResult.Success; } else return ActionResult.NotExecuted; } So assuming that I am not completely off track, how do I accomplish this task? To sum it up: I need to modify a xml file using a CA during installation, but before starting services. I have a work-around that actually works, where I simply perform the encryption in the CA and lets my installer handle the xml file modifications. I would like to know why this is not working though, and how I MAKE it work. Next time, it may not be possible to modify the file using only msi and wix. Any ideas? /Thomas ------------------------------------------------------------------------------ Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference _______________________________________________ WiX-users mailing list WiX-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wix-users