|
1 | 1 | # Out-of-process bootstrapper applications in WiX v5
|
2 | 2 |
|
3 |
| -:::info |
4 |
| -TODO: WiX v5 documentation is under development. |
| 3 | +In WiX v5, bootstrapper applications are separate processes and no longer hosted by the Burn process. The motivation for this change can be found in [#7916](https://github.com/wixtoolset/issues/issues/7916). This is obviously a significant breaking change so it was also taken as an opportunity to improve several .nupkg package names as described in [#8020](https://github.com/wixtoolset/issues/issues/8020). |
| 4 | + |
| 5 | +If using the WiX Standard Bootstrapper Application or WiX Internal UI Bootstrapper Application, the move to out-of-process bootstrapper applications is abstracted away and should not introduce any breaking changes. The rest of this document details changes required to custom bootstrapper applications. |
| 6 | + |
| 7 | +First, the custom bootstrapper application project needs to change from DLL to EXE. |
| 8 | + |
| 9 | +```diff |
| 10 | +exampleba.vcxproj |
| 11 | +- <ConfigurationType>DynamicLibrary</ConfigurationType> |
| 12 | ++ <ConfigurationType>Application</ConfigurationType> |
| 13 | +``` |
| 14 | + |
| 15 | +or |
| 16 | + |
| 17 | +```diff |
| 18 | +exampleba.csproj |
| 19 | ++ <OutputType>WinExe</OutputType> |
| 20 | +``` |
| 21 | + |
| 22 | +and reference the `WixToolset.BootstrapperApplicationApi` NuGet package (this one package replaces both the `WixToolset.BalUtil` and `WixToolset.Mba.Core` packages). |
| 23 | + |
| 24 | +As an executable, the boostrapper application needs a `main` function. Bootstrapper application main functions should be minimal to connect to the parent burn process as quickly as possible. For example, |
| 25 | + |
| 26 | +```cpp |
| 27 | +// exampleba.cpp |
| 28 | +EXTERN_C int WINAPI wWinMain( |
| 29 | + __in HINSTANCE hInstance, |
| 30 | + __in_opt HINSTANCE /* hPrevInstance */, |
| 31 | + __in_z_opt LPWSTR /*lpCmdLine*/, |
| 32 | + __in int /*nCmdShow*/ |
| 33 | + ) |
| 34 | +{ |
| 35 | + HRESULT hr = S_OK; |
| 36 | + IBootstrapperApplication* pApplication = new ExampleBootstrapperApplication(); |
| 37 | + |
| 38 | + hr = BootstrapperApplicationRun(pApplication); |
| 39 | + ExitOnFailure(hr, "Failed to run bootstrapper application."); |
| 40 | + |
| 41 | +LExit: |
| 42 | + ReleaseObject(pApplication); |
| 43 | + |
| 44 | + return 0; |
| 45 | +} |
| 46 | +``` |
| 47 | +
|
| 48 | +or |
| 49 | +
|
| 50 | +```cs |
| 51 | +// example.cs |
| 52 | + using WixToolset.BootstrapperApplicationApi; |
| 53 | +
|
| 54 | + internal class Program |
| 55 | + { |
| 56 | + private static int Main() |
| 57 | + { |
| 58 | + var application = new ExampleBoostrapperApplication(); |
| 59 | +
|
| 60 | + ManagedBootstrapperApplication.Run(application); |
| 61 | +
|
| 62 | + return 0; |
| 63 | + } |
| 64 | + } |
| 65 | +``` |
| 66 | + |
| 67 | +Notice that the bootstrapper engine and command objects are no longer passed to the creation of the bootstrapper application. Those values are not available until the application has been connected to the parent burn process in `Run()`. Therefore, there is a new `OnCreate()` bootstrapper application callback that provides both the bootstrapper engine and command objects. To keep the API balanced an `OnDestroy()` callback was also added. |
| 68 | + |
| 69 | +At this point, the bootstrapper application API is fairly compatible with only a few additional details to keep in mind. |
| 70 | + |
| 71 | +* Managed BootstrapperApplications no longer support changing "run async". BA's now always run their UI in a separate thread. |
| 72 | +* `BootstrapperApplicationFactory` concept no longer used. Remove all classes related to it. Create the BootstrapperApplication in the `main` function as shown above. |
| 73 | +* `BalBaseBootstrapperApplication.h` renamed `BootstrapperApplicationBase.h`. |
| 74 | +* `CBalBaseBootstrapperApplication` deprecated, use `CBootstrapperApplicationBase` instead. |
| 75 | + |
| 76 | +To take advantage of the breaking change, we took the opportunity to improve the names of many NuGet packages related to custom bootstrapper applications: |
| 77 | + |
| 78 | +* `WixToolset.BalUtil` - renamed to `WixToolset.BootstrapperApplicationApi` to provide the native headers and libraries to communicate Burn. Also, split out the `WixToolset.WixStandardBootstrapperApplicationFunctionApi` for WiX Standard Bootstrapper Application functions API. |
| 79 | +* `WixToolset.Mba.Core` - merged the managed headers into the `WixToolset.BootstrapperApplicationApi` so there is a single package for custom bootstrapper applications. |
| 80 | +* `WixToolset.BextUtil` - renamed to `WixToolset.BootstrapperExtensionApi`. |
| 81 | +* `WixToolset.Bal.wixext` - renamed to `WixToolset.BootstrapperApplications.wixext` but also kept` WixToolset.Bal.wixext` for backwards compatibility. |
| 82 | +* `WixToolset.Dnc.HostGenerator` - no longer relevant in WiX v5 and not available. |
| 83 | + |
| 84 | + |
| 85 | +:::tip |
| 86 | +Set a **SYSTEM** environment variable named `WixDebugBootstrapperApplications` to `true` to get a prompt to debug all boostrapper applications. Set a **SYSTEM** environment variable named `WixDebugBootstrapperApplication` to the file name of the bootstrapper application executable to get a prompt to debug that bootstrapper application. |
5 | 87 | :::
|
6 | 88 |
|
| 89 | + |
| 90 | +Related issues |
| 91 | + |
| 92 | +* [#7916 - BootstrapperApplication Processes](https://github.com/wixtoolset/issues/issues/7916) |
| 93 | +* [#8020 - Better Burn-related .nupkg names](https://github.com/wixtoolset/issues/issues/8020) |
0 commit comments