Create file in installation folder using WiX custom action

亡梦爱人 提交于 2019-12-11 12:34:20

问题


I try to create a wix installer that has the need to create a file in the programme folder after Installation. For doing so, I have created a custom action, but I now have the following problem:

In order to write the file, I need to know the installation directory from session["INSTALLDIR"], which is only available if the action is executed "immediate".

However, if i run "immediate" after "install files", the target directory does not yet exist. If I run "deferred", it exists, but i cannot access session["INSTALLDIR"].

If I run "immediate" after "InstallFinalize", I can get the variable and the directory exists, but I am not elevated and hence not allowed to write the file.

What is the correct combination for writing a file to the installation directory?


回答1:


You need to use CustomActionData to access property values from a deferred CA. You need something like this

or

another answer




回答2:


Beyond using a built in extension for custom actions instead of writing your own, the next level would be how can I move complexity / custom actions out of the installer?

One thought is to write it to the registry instead. Another thought is for the application reading the value to be able to determine installation directory on it's own. One possibility is reflection to get the location another possibility is to query the MSI API for where the product is installed.



来源:https://stackoverflow.com/questions/24808931/create-file-in-installation-folder-using-wix-custom-action

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