Replies: 3 comments 6 replies
-
Hi Frank, Thank you for such an insightful feedback. I actually agree with all your points. But I am not sure that making an additional elevated WixSharp_BeforeInstall_Action event is the best option. The reasons for this is not technical but rather API design-related. The initial rationale was to make all events immediate as the users almost always want to have access to the session properties (deferred actions are limited with that). Timing is also critical as often user wants to execute the action run right away. The only exception is the AfterInstall event: timing is not important (the session is over) and the need for elevation is more probable. And yet.... I had to implement Thus to satisfy your use case by updating WixSharp API I have the following options:
I am leaning towards #3. You? |
Beta Was this translation helpful? Give feedback.
-
Hello @oleg-shilo, Thank you for your quick reply and I'm looking forward to the solution. :-) Would you like to share your idea with me? It's nice that you have once again pointed out the implications of the different approaches.
WixSharp_BeforeInstall_Action wants to change the session object (change of ADDFEATURE) and this is not possible as a deferred CA. I understand that timing is important for users, but that's why you created WixSharp_Load_Action. This event is unelevated, has access to the session object and can make any preparations for the execution script. The time before InstallInitialize could possibly be relevant, but I haven't found a use case for that yet. But I can't think of a practical situation where a user would need an event to change the execution script while the execution script is being created. This is really very special, I think. I understand that WixSharp_BeforeInstall_Action can't suddenly be elevated. So at the moment I actually think only an additional CA e.g. WixSharp_BeforeInstall_Action_Elevated could be a solution. And something else. I'm really impressed by how many years you've been supporting this project. Thank you very much for everything. If you should ever be in Hamburg or anywhere in Germany, please write beforehand. Then we can talk about our projects if you like. Best regards Frank |
Beta Was this translation helpful? Give feedback.
-
Done. The latest release v2.2.0 allows controlling the hosting environment of the managed events (custom actions). project.BeforeInstallEventExecution = EventExecution.MsiSessionScopeImmediate;
project.BeforeInstallEventExecution = EventExecution.MsiSessionScopeDeferred;
project.BeforeInstallEventExecution = EventExecution.ExternalElevatedProcess;
// the same for Load and AfterInstall events This is the code sample in the repository: https://github.com/oleg-shilo/wixsharp/blob/wix-v4-master/Source/src/WixSharp.Samples/Wix%23%20Samples/InstallEventElevation/setup.cs |
Beta Was this translation helpful? Give feedback.
-
Hello @oleg-shilo,
we would like to move our CustomActions to the event functions (Load, BeforeInstall, AfterInstall) to simplify our source code.
Unfortunately, this is not possible for certain actions that need to be executed before InstallFiles (in WixSharp_BeforeInstall_Action) because they need to run with elevated privileges.
WixSharp_BeforeInstall_Action is an immediate CustomAction and therefore functions with elevated rights cannot be executed.
The reason WixSharp_BeforeInstall_Action is an immediate CustomAction is that it requires the session object to customize the ADDFEATURES property. But in my opinion, this should be a completely separate CustomAction.
My understanding is that immediate actions executed between InstallInitialize InstallFinalize should only be used to customize the execution script.
WixSharp_AfterInstall_Action is a deferred CustomAction and so it is possible to execute different things with system rights.
We do not want to recommend the user to open a command shell as administrator every time and then perform the installation with msiexec.
"project.InstallPrivileges = InstallPrivileges.elevated;" is set.
What is your opinion on this?
Kind regards
Frank
Beta Was this translation helpful? Give feedback.
All reactions