2

I need to pass data from one deferred .NET custom action to another, but I can't figure out how to do this.

Deferred custom actions can't access the Windows Installer session, so session properties are not an option. The target deferred custom action is already taking custom action data that is set from an earlier immediate custom action, but I don't seem to be able to modify this from the source deferred action.

I've also tried using static properties on the custom action class, but as expected, that doesn't work either.

I could write to the registry in the source action and read it back in the target action, but that seems somewhat hacky. Surely there is a more standard way to pass data between deferred custom actions?

Cocowalla
  • 13,822
  • 6
  • 66
  • 112

3 Answers3

5

Yes, good quesion.

Surely there is a more standard way to pass data between deferred custom actions?

No, as far I know, there is no such standard system.

To be completely honest, it's already miracle that deferred actions can read properties through CustomActionData - that's done through some kind of metadata when generating the execution script. Deferred actions can access only few limited properties, and it can't interact with the MSI database.

See Obtaining Context Information for Deferred Execution Custom Actions for more. It's not WiX limitation, but MSI.

As you said, either look into temp folders or registry - although not necessarily convenient or nice - it will work very nicely if done carefully.

If you're interested understanding more about MSI architecure, this is very good link: http://bonemanblog.blogspot.co.uk/2005/10/custom-action-tutorial-part-i-custom.html

Erti-Chris Eelmaa
  • 25,338
  • 6
  • 61
  • 78
1

There's intentionally no way to do this because this isn't the design intention. The intention is for an immediate custom action to do all business logic / data processing and to pass instructional data to deferred custom actions that do the actual elevated work / system changes.

Christopher Painter
  • 54,556
  • 6
  • 63
  • 100
0

WiX provides a native-code library for doing this in wcautil.lib. See https://github.com/wixtoolset/wix3/blob/develop/src/libs/wcautil/wcascript.cpp. (We needed it for the IIS custom actions because IIS breaks the "rule" that standard users should be able to read configuration, if not write it.)

Bob Arnson
  • 21,377
  • 2
  • 40
  • 47
  • Can you elaborate a bit about how I can use this in my scenario? (it's not at all clear to me from the few comments in the code) – Cocowalla Dec 23 '14 at 21:09
  • You can see it in use at https://github.com/wixtoolset/wix3/blob/develop/src/ext/ca/wixca/dll/serviceconfig.cpp. WcaCaScriptWriteString and WcaCaScriptWriteNumber let you write custom action data just like an immediate custom action. – Bob Arnson Dec 24 '14 at 01:24
  • Ah, I should have mentioned that my custom actions are in .NET. `wcautil` doesn't appear to be available for .NET. – Cocowalla Dec 24 '14 at 20:58