Search code examples
wix.net-6.0wix4

Unable to launch custom .NET 6 BA with WixDotNetCoreBootstrapperApplicationHost


I'm converting a WIX3/.NET4.8 installer to WIX4/.NET6. At the moment, I'm trying to see from the bundle our custom BA, which was converted to .NET6.

But I still get these errors on a fresh Win 11 VM, when launching the installer bundle:

Error 0x800700c1: Failed to load hostfxr from 'C:\Windows\TEMP\{2198BC7C-AA74-4DBC-A488-F62A6AD921AE}\.ba\hostfxr.dll'.
Error 0x800700c1: Failed to load hostfxr.
Error 0x800700c1: The self-contained .NET Core runtime failed to load. This is an unrecoverable error.

Bundle and BA settings:

  • the bundle use WIX 4.0.0-rc.2, and target x64
  • it has a BA with <bal:WixDotNetCoreBootstrapperApplicationHost SelfContainedDeployment="yes"/>
  • the payload is harvested by heat, with the correct <Payload bal:BAFactoryAssembly="yes" SourceFile="$(var.InstallerUIPath)\VisionMainInstallerUI.exe" xmlns:bal="http://wixtoolset.org/schemas/v4/wxs/bal" />
  • the custom BA is publish self-contained for runtime win-x86
  • the custom BA is targeting net6.0-windows/win-x86 (I discovered that x86 was still mandatory, as mbanative.dll is only x86)

As I have set the BA as executable (console) I'm able to launch it and see the console message from C:\Windows\TEMP{2198BC7C-AA74-4DBC-A488-F62A6AD921AE}.ba
I was previously creating a dll, but I had the same error, and the exe permit me to check that the self-contained is working and not missing anything.

I also tried the framework dependent solution, with installing the .NET runtime. But I get the same errors:

The prerequisites were successfully installed. The bootstrapper application will be reloaded.
Bootstrapper application requested to be reloaded.
Error 0x800700c1: Failed to load hostfxr from 'C:\Windows\TEMP\{6D909B1C-378D-4481-96DE-DCF7ADBDBBA4}\.ba\hostfxr.dll'.
Error 0x800700c1: Failed to load hostfxr.
Error 0x81f403ea: The prerequisites were already installed. The bootstrapper application will not be reloaded to prevent an infinite loop.
Loading prerequisite bootstrapper application because .NET Core host could not be loaded, error: 0x81f403ea.

Finally, I also tried our test program, which emulate WIX for UI testing the BA: even in self-contained, without any runtime on the VM, the BA was correctly displayed.

Even if I struggle quite a bit to get the correct self-contained output, and the needed harvesting result, I have now a BA which is working when directly called, but WIX still don't want to start it. I now don't know what to do, as the errors messages are totally misleading (hostfxr.dll being present, and the BA is starting on its own).

Update

I switched again to win-x64 (for both build and publishing self-contained) and to a dll output, and I now get the errors bellow. mbanative.dll correctly contains "PE\0\0d", therefore it is the 64 bit version (Dependencies GUI x64 misleads by marking an issue on it)

My test application emulating WIX can also use the BA dll in x64, and the UI is displayed without issue on a VM without .NET6 runtime. It is only from the bundle itself that it isn't working.

[1E3C:08BC][2023-02-08T10:23:02]e000: error from hostfxr: You must install or update .NET to run this application.

App: C:\Windows\TEMP\{8521A191-8C06-4ED8-880A-4FE878955375}\.cr\visionCATS.exe
Architecture: x64
[1E3C:08BC][2023-02-08T10:23:02]e000: error from hostfxr: Framework: 'Microsoft.NETCore.App', version '6.0.0' (x64)
[1E3C:08BC][2023-02-08T10:23:02]e000: error from hostfxr: .NET location: C:\Windows\TEMP\{414A222D-3B83-4894-8FC0-5AD87CF921E3}\.ba\

[1E3C:08BC][2023-02-08T10:23:02]e000: error from hostfxr: No frameworks were found.
[1E3C:08BC][2023-02-08T10:23:02]e000: error from hostfxr: 
Learn about framework resolution:
https://aka.ms/dotnet/app-launch-failed

To install missing framework, download:
https://aka.ms/dotnet-core-applaunch?framework=Microsoft.NETCore.App&framework_version=6.0.0&arch=x64&rid=win10-x64
[1E3C:08BC][2023-02-08T10:23:02]e000: Error 0x80008096: HostfxrInitializeForApp failed
[1E3C:08BC][2023-02-08T10:23:02]e000: Error 0x80008096: Failed to initialize hostfxr.
[1E3C:08BC][2023-02-08T10:23:02]e000: Error 0x80008096: The self-contained .NET Core runtime failed to load. This is an unrecoverable error.
[1E3C:08BC][2023-02-08T10:23:02]i000: Loading prerequisite bootstrapper application because .NET Core host could not be loaded, error: 0x80008096.

Solution

  • I discovered that x86 was still mandatory, as mbanative.dll is only x86

    This is not correct. mbanative.dll is available in x86, x64, and ARM64. As long as your BA's project file is SDK-style, it's as simple as building with the win-x64 RID for an x64 bundle.

    You must build your BA in the same architecture as the bundle. That's what 0x800700c1 (ERROR_BAD_EXE_FORMAT) is trying to tell you.