-
Notifications
You must be signed in to change notification settings - Fork 1
Phases Overview
The installation of the bundle happens in three phases.
- Detect
- Plan
- Apply
The classes in the Bootstrapper.Phases
namespace contain event handlers for these phases. These classes direct and manage the install. The events are triggered while Windows Installer works on evaluating and applying the bundle.
Both Windows Installer and WiX use HRESULTs to provide the result of operations. Most event arguments (if not all) passed to your handlers have an HResult
property that you can use to pass an HRESULT back to the engine. Events that report completion of tasks include an additional Status
property which contains the engine's HRESULT of that operation.
I suggest not using the HResult
property to report errors. Throw an exception instead. I've found returning an HRESULT back to be hit and miss. Sometimes the install will fail and roll back appropriately, but other times the result is ignored. Throwing an exception does a better job of getting the engine's attention.
You can, and probably should, check the Status
property for engine results and handle them appropriately. A good time to do this is when a phase completes.
if (ErrorHelper.HResultIsFailure(e.Status))
{
// Handle result
return;
}
I suggest logging all exceptions in your event handlers. Don't count on WiX to log them for you.
try
{
// Handle event
}
catch (Exception ex)
{
log.Write(ex);
throw;
}