Unable to launch custom .NET 6 BA with WixDotNetCoreBootstrapperApplicationHost - wix

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.

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.

Related

Unable to launch custom .NET 6 BA with WixDotNetCoreBootstrapperApplicationHost in x64

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.
See previous question with more background
With the BA set to win-x64 (for both build and publishing self-contained) and to a dll output, I get the errors bellow.
[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.
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.

msbuild GenerateDepsFile fails

All my projects are not failing to build on my Azure DevOps MacOS build host. It's a self-hosted build host. Suddenly, my projects are throwing this error when trying to build:
error MSB4018: The "GenerateDepsFile" task failed unexpectedly.
error MSB4018: System.MissingMethodException: Method not found: System.Collections.Generic.IList`1<NuGet.Packaging.Core.PackageDependency> NuGet.ProjectModel.LockFileTargetLibrary.get_Dependencies()
I found this GitHub issue which seemed similar, but the posted solution didn't help me:
https://github.com/mono/mono/issues/13537
As mentioned in xamarin/xamarin-android#3155 this is caused by a version mismatch in nuget between msbuild and dotnet core. The solution is to update your dotnet core install to the latest stable version
I've installed the most recent .NET Core, and updated Visual Studio for Mac, but alas, the problem remains.
Another information:
When I build the same Xamarin.iOS project from my Windows machine coupled with the same MacOS build host, the app builds just fine. But I am guessing the process is probably different.
Updating both Visual Studio for Mac and .NET Core SDK again today seems to have fixed the problem.

Running Wix bundle installer fails during installation

I have created an installation bundle using Wix3.5. Within a Bundle I created a Chain element to install prerequisites (VC Runtime and another inhouse application's installer) before installing the main application. The other inhouse application's installer was created with Installaware. Now the main installation fails after the Installaware installer finishes with this error message in the installer window:
0x80070064 - Cannot create another system semaphore
Excerpt from the installer log:
[2750:1D60][2019-02-28T16:08:58]e000: Error 0x80070064: Process returned error: 0x64
[2750:1D60][2019-02-28T16:08:58]e000: Error 0x80070064: Failed to configure per-user EXE package.
[2750:1D60][2019-02-28T16:08:58]i319: Applied execute package: CEInstaller, result: 0x80070064, restart: None
[2750:1D60][2019-02-28T16:08:58]e000: Error 0x80070064: Failed to execute EXE package.
However, it seems that the bundled application is installed correctly and can be run as well.
After trying to bundle some other installers instead for testing, it seems that this error only occurs with our Installaware inhouse applications but not with other third party installers. I went through the corresponding Installaware logs but did not find anything suspicious (As these are huge I refrained from posting them here for now).
I am pretty much stuck with this issue (also I am quite new working with Windows installer frameworks). Searching online did not deliver any helpful results so far, so I am grateful for any hints how to solve or further investigate this issue.

Bootstrapper not loading on Windows Server 2008 r2

Hola Stackoverflowians
Testing my bootstrapper on Windows Server 2008, it doesn't launch, it just crashes with this log:
[07E8:0560][2013-07-16T11:36:31]e000: Error 0x80070002: Failed to create the managed bootstrapper application.
[07E8:0560][2013-07-16T11:36:31]e000: Error 0x80070002: Failed to create UX.
[07E8:0560][2013-07-16T11:36:31]e000: Error 0x80070002: Failed to load UX.
[07E8:0560][2013-07-16T11:36:31]e000: Error 0x80070002: Failed while running
[07E8:0560][2013-07-16T11:36:31]e000: Error 0x80070002: Failed to run per-user mode.
[07E8:0560][2013-07-16T11:36:31]i007: Exit code: 0x80070002, restarting: No
It's a completely clean installation of Windows, so it only has .NET 2.0 installed.
And my bootstrapper is built against 3.0 and I've got this in my BootstrapperCore.config
<supportedRuntime version="v2.0.50727" sku=".NETFramework,Version=v3.0" />
As far as my searches has gone, 0x80070002 = FILE_NOT_FOUND. "Which file is that?"
Using Process Monitor I couldn't see any File Not Found other than some .NET/System Restore components. None of which I expect to be there in this setup anyway, so ultimately this didn't help.
In this scenario (Current .net version < Required .net version) I would expect the prerequisites installer to kick in, but it doesn't.
Why doesn't the prereq installer start? And how does one go about debugging these type of errors with Burn? These messages aren't really all that helpful at all.
Thanks
EDIT: Does this mean you can not have a bootstrapper target .NET 3.0?

Windows Installer from .Net 2.0 Custom Action to .Net 4.0 Custom Action - BadImageFormatException

I'm having a problem with an application that I recently upgraded from .Net 2.0 to .Net 4.0. During installation, the custom action starts to execute and throws an error.
=== Logging started: 9/30/2011 2:34:09 ===
Error 1001. Error 1001. Exception occurred while initializing the installation:
System.BadImageFormatException: Could not load file or assembly 'file:///C:\Program Files\MyPath\MyCustomAction.dll' or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded..
=== Logging stopped: 9/30/2011 2:34:30 ===
Note that should I uninstall the old version of the application first, then install the new version of the application, the installation succeeds without error.
The only thing I can guess is that the .Net 2.0 custom action is failing to be loaded by Windows Installer as it's not the same .Net 4.0 framework as used by the latest version of my application. Has anyone run into this?
You've got to set the condition for the runtime in the vdproj (it doesn't update with your custom action project):
http://msdn.microsoft.com/en-us/library/kz0ke5xt.aspx
In Solution Explorer, click the Setup project.
On the View menu, point to Editor, and then click Launch Conditions.
Click .NET Framework.
In the Properties window, change the Version property to the version of the .NET Framework that you want the Setup project to check for and install.