oleg-shilo / wixsharp

Framework for building a complete MSI or WiX source code by using script files written with C# syntax.
MIT License
1.12k stars 176 forks source link

The installation directory value is incorrect #1530

Closed JusterWork closed 5 months ago

JusterWork commented 6 months ago

If I don't manually re-select the InstallDirPath directory in the InstallDirDialog interface, accessing "Host?.Runtime.InstallDir" in the InstallExitDialog interface will have no value.

I am using wixsharp-wix.WPF2.1.2, and the problem occurs in the dialog provided by the project template.

oleg-shilo commented 6 months ago

It is a tricky one.

Host?.Runtime.InstallDir can only be reliably assessed when the msi session is in progress. And ExitDialog is the first dialog that is displayed after the session is terminated.

So what you can do is store the InstallDir value in some repository that lives in the same process with the dialogs. And then you can read this value in the exit dialog. Mind you that the convoluted MSI runtime model is ridiculously old thus every single custom action is executed in a separate process.

Though I would encourage you to consider moving out the action that you are trying to do from the ExitDialog to the msi AfterInstall event (custom action). If it fits your deployment scenario. Then you do not need to do anything. The even arg already has a proper installdir (either default or changed). And the event itself is already elevated. image

JusterWork commented 5 months ago

oleg, thank you