Pass data between deferred custom action

天大地大妈咪最大 提交于 2019-12-11 02:37:50

问题


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?


回答1:


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




回答2:


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.




回答3:


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



来源:https://stackoverflow.com/questions/27594036/pass-data-between-deferred-custom-action

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!