[wix-users] Forced reboot behavior during bundle install with custom bootstrapper application

Bryan Dam bryand at recastsoftware.com
Thu Apr 14 09:35:29 PDT 2022


TL;DR: In my custom BootStrapperApplication's Shutdown event I am (for testing only) hard coding e.Result = Result.Restart but the OS doesn't reboot when my bootstrapper application closes.  What's the expected behavior here? I though it would forcibly restart the OS.


I've got a bundle that needs to install IIS before it installs the .Net Core Hosting Bundle before it installs our app.  If IIS isn't there before the .Net Core install then it won't install the IIS features and thus our app will install but fail to run.  I have an EXE project called InstallIIS that uses DISM to install IIS and the necessary modules.  It uses the /noreboot flag which means that sometimes DISM returns 3010 which my EXE returns as its own exit code.  When a reboot is needed I need to make sure the OS reboots before the bundle install continues on to .Net Core.

So in the InstallIIS ExePackage element I've added: <ExitCode Value="3010" Behavior="forceReboot" />

My custom boostrapper application handles ApplyComplete that checks the e.Restart value and if it's RestartRequired or RestartInitialized will prompt the user to reboot now or reboot later themselves.

My custom boostrapper application also handles  Shutdown and if the user has chosen to reboot now sets e.Result accordingly:
private void BootstrapperUI_Shutdown(object sender, ShutdownEventArgs e)
{
//if (_vm.RebootAccepted)- Commented out for testing
e.Result = Result.Restart;
}

This all appears to work.  InstallIIS runs, returns 3010, I get the reboot prompt from my custom bootstrapper application, and e.Result is set to Result.Restart.  However, my custom bootstrapper application closes and the OS does not reboot.  If I manually reboot and manually rerun the installer then I can see that BootStrapperApplication.Command.Resume equals ResumeType.Reboot but the actual reboot doesn't appear to be triggered as I expected to.  Am I doing something wrong or just have incorrect expectations?

  Thank,
    Bryan

Here's a truncated bundle log:
=======================================
Applied execute package: InstallIIS, result: 0x0, restart: Initiated
Session end, registration key: SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{a86bc6fc-e90b-4a89-964c-8c52893ad3e5}, resume: Reboot Pending, restart: Initiated, disable resume: No
Updating session, registration key: SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{a86bc6fc-e90b-4a89-964c-8c52893ad3e5}, resume: Reboot Pending, restart initiated: Yes, disable resume: No
Apply complete, result: 0x0, restart: Initiated, ba requested restart:  No
Shutting down, exit code: 0x0
Bootstrapper application requested restart at shutdown. Planned to restart already: No.
...
Variable: RebootPending = 0
...
Variable: WixBundleForcedRestartPackage = InstallIIS
...
Exit code: 0x0, restarting: Yes
Restarting computer...
=======================================


More information about the wix-users mailing list