2
votes

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?

3

3 Answers

5
votes

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

1
votes

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.

0
votes

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.)