Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bootstrapper Custom BA (WiX4) problems and current status #1671

Open
frnds1 opened this issue Nov 12, 2024 · 17 comments
Open

Bootstrapper Custom BA (WiX4) problems and current status #1671

frnds1 opened this issue Nov 12, 2024 · 17 comments

Comments

@frnds1
Copy link

frnds1 commented Nov 12, 2024

Building the current template for Bootstrapper Custom BA (WiX4) in VS 2022 17.11.5 yields several problems instead of displaying the XAML dialog like the WiX3 template.

Removing the DisplayInternalUI setting and adding the PlansMsiPackage settings, eliminates the warnings and references to the discussion. However, there is still a build warning:

Custom BA payloads are missing 'WinToolset.BootstrapperApplicationAPI.dll'

After running there are two errors:
WIX0103: Cannot find the File file 'Program.cs'. Tje following paths were checked: Program.cs
WIX0407: There is no payload define for package 'MyProductPackageId'. This is specified on the MsiPackage element or child MsiPackagePayload element.

Cannot build ... setup.wxs
Exit code 0.

Running the MyProduct.exe generated displays the Prerequisite required for MyProduct setup dialog.

Are there adjustments to the WiX4 template to eliminate these errors and yield the XAML dialog display like the WiX3 template?

@oleg-shilo oleg-shilo added the bug label Nov 12, 2024
@oleg-shilo
Copy link
Owner

Thank you for reporting it.
Will have a look asap.

@oleg-shilo
Copy link
Owner

I just tested it.

The only problem I had was that the project target runtime version was lower than the WixSharp nuget package has. I updated it manually and after that project builts fine and XAML designer is displayed OK too:

image

Note there is a strange XLS error on loading the designer but it seems to have no impact on anything. designer works correctly, bundle builds and runs fine.

I will update the template. But in a meantime, you can use the attached project as a template.
WixSharp Setup - Bootstrapper Custom BA (WiX4)1.zip

@frnds1
Copy link
Author

frnds1 commented Nov 12, 2024

Thank you. I hit the 4.6.2 issue on the first build and switched to 4.7.2. I get the same results with your zip file--same warnings and errors. When I run the MyProduct.exe I get the same license dialog instead of the XAML dialog:
BootstrapperWix4Template

@oleg-shilo
Copy link
Owner

Can you share with me your update project with the binaries? I want to investigate it.

@frnds1
Copy link
Author

frnds1 commented Nov 14, 2024

Thank you. Here is WiX4 Bootstrapper template project.
WixSharp Setup - Bootstrapper Custom BA (WiX4)1.zip

@oleg-shilo
Copy link
Owner

oleg-shilo commented Nov 17, 2024

OK, your project is perfectly fine.
It's probably the tools that you are using that are doing the damage.

The problem is that the template you are using was designed for the WiX4 tools. However, I suspect that on your environment you have WiX5 tools installed.

Thus in order to fix it it was enough to just put this line in the build script:

WixTools.SetWixVersion(Environment.CurrentDirectory, "4.0.0");

This is required as WiX5 Custom BA hosting has dramatically changed, so you need to downgrade the BA hosting model. Previously, Custom BA was just an assembly (DLL) with the entry point being specially marked with the WiX attribute. In WiX5 the BA is a standalone executable that does not use any attributes and simply communicates with the WiX runtime via IPC.

Though WixSharp already comes with the example of hosting custom BA for WiX5, that example has not yet been released as a template. That's why I recommend that you downgrade your tools.

Anyway, just to show you how one can build a custom BA for WiX4 and WiX5 I have updated your sample (attached). Now it contains

  • WiX4 custom UI with the UI code included in the WixSharp project
  • WiX5 custom UI official WiX example added as a separate project WixSharp project solution.

#1671.zip

I have updated (0a6c6da) the template WiX4 to set the tools to the WiX4 version and ensure the compatible Custom BA hosting model.

@frnds1
Copy link
Author

frnds1 commented Nov 18, 2024

Thank you. I checked. On this system, on Wix 5 was installed because that was the current that defaulted. I did a build on your new project and have several errors. I installed Wix 4, but that didn't help. I tried installing the extensions manually per the error messages, but that did not improve things. I was able to build and run the WixBA.5 project. How do I uninstall Wix 5 and ensure I have the correct version of 4 for your template?

Here are the errors:

1>Compiling MyProduct.wxs
1>Source base directory: C:\Users\Chant Development\Documents\Support\WixSharp\1671\WixSharp Setup - Bootstrapper Custom BA (WiX4)1
1>EXEC : error : Cannot find WiX extension 'WixToolset.UI.wixext'. WixSharp attempted to install the extension but did not succeed. Please install the extension manually with: wix.exe extension add -g WixToolset.UI.wixext
1>wix.exe : error WIX0144: The extension 'C:\Users\Chant Development\Documents\Support\WixSharp\1671\WixSharp Setup - Bootstrapper Custom BA (WiX4)1\MyProduct.wxs' could not be loaded because of the following reason: Could not load file or assembly 'C:\Users\Chant Development\Documents\Support\WixSharp\1671\WixSharp Setup - Bootstrapper Custom BA (WiX4)1\MyProduct.wxs'. Format of the executable (.exe) or library (.dll) is invalid.
1>C:\Users\Chant Development\Documents\Support\WixSharp\1671\WixSharp Setup - Bootstrapper Custom BA (WiX4)1
1>
1>EXEC : warning : DisplayInternalUI value of MsiPackages will be ignored because you are using custom BA. For custom BA applications visibility of the individual MSI packages needs to be controlled from the PlanMsiPackage event handler of the BA.
1>Read more here: #1396 (comment)
1>
1>
1>----------------------------------------------------------
1>
1>Wix project file has been built: C:\Users\Chant Development\Documents\Support\WixSharp\1671\WixSharp Setup - Bootstrapper Custom BA (WiX4)1\setup.wxs
1>
1>EXEC : error : Cannot find WiX extension 'WixToolset.Netfx.wixext'. WixSharp attempted to install the extension but did not succeed. Please install the extension manually with: wix.exe extension add -g WixToolset.Netfx.wixext
1>EXEC : error : Cannot find WiX extension 'WixToolset.Bal.wixext'. WixSharp attempted to install the extension but did not succeed. Please install the extension manually with: wix.exe extension add -g WixToolset.Bal.wixext
1>Cannot build C:\Users\Chant Development\Documents\Support\WixSharp\1671\WixSharp Setup - Bootstrapper Custom BA (WiX4)1\setup.wxs
1>C:\Users\Chant Development\Documents\Support\WixSharp\1671\WixSharp Setup - Bootstrapper Custom BA (WiX4)1\WixSharp Setup - Bootstrapper Custom BA (WiX4)1.csproj(33,5): error MSB3073: The command "cd .
1>C:\Users\Chant Development\Documents\Support\WixSharp\1671\WixSharp Setup - Bootstrapper Custom BA (WiX4)1\WixSharp Setup - Bootstrapper Custom BA (WiX4)1.csproj(33,5): error MSB3073: set ide=true
1>C:\Users\Chant Development\Documents\Support\WixSharp\1671\WixSharp Setup - Bootstrapper Custom BA (WiX4)1\WixSharp Setup - Bootstrapper Custom BA (WiX4)1.csproj(33,5): error MSB3073: "C:\Users\Chant Development\Documents\Support\WixSharp\1671\WixSharp Setup - Bootstrapper Custom BA (WiX4)1\bin\Release\net472\WixSharp Setup - Bootstrapper Custom BA (WiX4)1.exe"" exited with code -1.
1>Done building project "WixSharp Setup - Bootstrapper Custom BA (WiX4)1.csproj" -- FAILED.

@oleg-shilo
Copy link
Owner

How do I uninstall Wix 5...

WiX4+ is distributed as a .NET Tool it's a .NET native application packaging mechanism. So you you want to remove a tool then you need to find the required command with dotnet tool -?

However, you do not need to uninstall WiX5/4.
The project I shared with you shows how to tell your WixSharp compilation which of the installed WiX versions should be used for the MSI build: WixTools.SetWixVersion(Environment.CurrentDirectory, "4.0.0"); The last argument is the version of the installed WiX tool that you want to use.

Now, about the problem you are experiencing. You probably noticed that the error message explained to you the cause of the error - the absence of the WiX extension package on your system. It even gave you a suggestion on how to install the package manually: wix.exe extension add -g.... Thus if execute these two commands it suggested you will be able to install the missing extensions. Probably, it's better to use the latest version of your wix.exe for installing the package.

The interesting bit is that WixSharp proactively tries to install the extension:

image

I think the package installation has failed for some reason so WixSharp suggests you do it manually. If you do that then you may even see if indeed the extension package installation fails and why.

@frnds1
Copy link
Author

frnds1 commented Nov 24, 2024

Thank you. I originally ran the console commands to see if they made any difference but it didn't. I did run the following from console command line:

wix extension list
WixToolset.Bal.wixext 5.0.2 (damaged)
WixToolset.Netfx.wixext 5.0.2
WixToolset.UI.wixext 5.0.2

Could this be the cause and is there a way to fix?

@oleg-shilo
Copy link
Owner

oleg-shilo commented Nov 25, 2024

Yes, indeed it can be the cause. In fact, most likely.

I did not realize that wix can detect the damaged packages. Great feature.

You can try to fix the extension manually. It will be something like wix extension add -g WixToolset.Bal.wixext.
You may need to uninstall and then install it again.
Obviously, for some reason the extension was not installed correctly.

@frnds1
Copy link
Author

frnds1 commented Nov 26, 2024

Thank you. I found much discussion about the (damaged) problem. The discussion seems to indicate that you must be version-specific when requesting an install.

I removed all the extensions. Then ran your latest project. However, it had issues and generated the following result:

wix extension list
WixToolset.Bal.wixext : warning WIX6101: Could not find expected package root folder wixext5. Ensure WixToolset.Bal.wixext/5.0.2 is compatible with WiX v5.
WixToolset.Netfx.wixext : warning WIX6101: Could not find expected package root folder wixext5. Ensure WixToolset.Netfx.wixext/5.0.2 is compatible with WiX v5.
WixToolset.UI.wixext : warning WIX6101: Could not find expected package root folder wixext5. Ensure WixToolset.UI.wixext/5.0.2 is compatible with WiX v5.
WixToolset.Bal.wixext 5.0.2 (damaged)
WixToolset.Netfx.wixext 5.0.2 (damaged)
WixToolset.UI.wixext 5.0.2 (damaged)

To clarify, it appeared the Wix3 template ran without issue and requiring extensions, but the Wix4 requires extensions. Is it possible to know the exact Wix utility and extension command lines to install a specific version to avoid this complexity and just run either a Wix3 bootstrap or Wix4 bootstrap as you originally illustrated?

@oleg-shilo
Copy link
Owner

Sorry about the delay.

I removed all ....However, it had issues...

It's kinda consistent with your prev description. For some reason deploying WixToolset extensions is problematic on your environment. WixSharp tries to do it on your behalf but it leads to no result. That's why I wanted you manually execute what WixSharp normally does in background if the extension is not found.

Thus removing all extensions and rebuilding the project confirmed that it was no accident but a persistent problem.
I suggest you remove the extensions again and before building the project install the extensions manually. IE:

wix extension add -g WixToolset.Bal.wixext

Then WixSharp will be able to find them, providing you managed to install them.

tility and extension command lines to install a specific
Yes you will need to check the wix Hdocumentation. But even in this repo users shared the command line for that. so I am sure it can be done.

If you want to guide WixSharp to use a specific version then you can just place this instruction(s) in your code before compiling the project:

WixExtension.UI.PreferredVersion = "4.0.4";

appeared the Wix3 template ran without issue

Correct. WiX4 was the one that introduced this new mechanizm

@oleg-shilo
Copy link
Owner

You can send me the bundle build command and I can check which versions of the required extensions are compatible by testing it in my environment. You can generate the command by calling bootstrapper.BuildCmd("build_setup.cmd");

And I found the installation command for you. It is in fact in an WixSharp codebase:
wix extension add -g extensionId/version

@frnds1
Copy link
Author

frnds1 commented Nov 28, 2024

Thank you. The original install for Wix defaulted to Wix 5.0.2 tools. If I try to install the v4 extension it fails:
wix extension add -g WixToolset.Bal.wixext/4.0.4
WixToolset.Bal.wixext : warning WIX6101: Could not find expected package root folder wixext5. Ensure WixToolset.Bal.wixext/4.0.4 is compatible with WiX v5.

So, is that saying I can't run with V4 with a 5.0.2 install because it can't be configured and would have to run as a V5 install because now the Bal extension is required (unlike Wix3)?

If I run wix extension add -g WixToolset.Bal.wixext
I get:

wix extension list
WixToolset.Bal.wixext 5.0.2 (damaged)

What am I looking for: "send me the bundle build command"? .wxs file?

@oleg-shilo
Copy link
Owner

Then you are out of luck.

As a vendor, I would aim for all the latest versions of my extensions to run with the latest version of my compilers. But WiX team has its own product release strategy which, is very different to the usual practices. I found it puzzling but I accept it's other right to do so.

When WiX5 was just released, the building bundle got broken for the very same compatibility reason. I will leave it to the WiX team to manage the compatibility of their releases. I had a very bad experience with them so I do not want to engage with them any more.

Anyway, I have checked and in my environment, I can successfully compile with wix 5.0.2+aa65968c and the extension of the
image

If you fix that WixToolset.Bal.wixext 5.0.2 (damaged) then you solve your problem. But the fix will be about the WiX and its extensions deployment.

You can cheat the system by manually extracting the files from the extension and placing them in the location from the screenshot above. WixToolset.Bal.wixext is just a zip file. You can easily open and copy files to the user profile location.

Sorry, this is as much as I can help you as it's not WixSharp but WiX problem. It's not much I can do there..

@frnds1
Copy link
Author

frnds1 commented Nov 30, 2024

Thank you. I asked over on WixToolset project and received this response that the extension was renamed in Wix5:
https://github.com/orgs/wixtoolset/discussions/8852#discussioncomment-11420431

Document changes here: https://wixtoolset.org/docs/fivefour/oopbas/

I was able to install the extension with new name undamaged. When I run the latest template with WixTools 5, it builds. However, MyProduct.exe, I get a Hello Word message box, then default msi dialog. I do not see the xaml bootstrap dialog.

When I run the latest template with WixTools 4, build fails. I get error messages for the older name as damaged. Before running template:

wix extension list
WixToolset.BootstrapperApplications.wixext 5.0.2
WixToolset.Netfx.wixext 5.0.2
WixToolset.UI.wixext 5.0.2
WixToolset.Util.wixext 5.0.2

After running new template (set to use WixTools 4,):

wix extension list
WixToolset.Bal.wixext : warning WIX6101: Could not find expected package root folder wixext5. Ensure WixToolset.Bal.wixext/5.0.2 is compatible with WiX v5.
WixToolset.Bal.wixext 5.0.2 (damaged)
WixToolset.BootstrapperApplications.wixext 5.0.2
WixToolset.Netfx.wixext 5.0.2
WixToolset.UI.wixext 5.0.2
WixToolset.Util.wixext 5.0.2

The project failed build messages:
WixSharp Setup - Bootstrapper Custom BA (WiX4)1 -> C:\Users\A User\Documents\Support\WixSharp\1671\WixSharp Setup - Bootstrapper Custom BA (WiX4)1\bin\Release\net472\WixSharp Setup - Bootstrapper Custom BA (WiX4)1.exe
Wix version: 4.0.0


Wix project file has been built: C:\Users\A User\Documents\Support\WixSharp\1671\WixSharp Setup - Bootstrapper Custom BA (WiX4)1\MyProduct.wxs

Compiling MyProduct.wxs
Source base directory: C:\Users\A User\Documents\Support\WixSharp\1671\WixSharp Setup - Bootstrapper Custom BA (WiX4)1
EXEC : error : Cannot find WiX extension 'WixToolset.UI.wixext'. WixSharp attempted to install the extension but did not succeed. Please install the extension manually with: wix.exe extension add -g WixToolset.UI.wixext
wix.exe : error WIX0144: The extension 'C:\Users\A User\Documents\Support\WixSharp\1671\WixSharp Setup - Bootstrapper Custom BA (WiX4)1\MyProduct.wxs' could not be loaded because of the following reason: Could not load file or assembly 'C:\Users\A User\Documents\Support\WixSharp\1671\WixSharp Setup - Bootstrapper Custom BA (WiX4)1\MyProduct.wxs'. Format of the executable (.exe) or library (.dll) is invalid.
C:\Users\A User\Documents\Support\WixSharp\1671\WixSharp Setup - Bootstrapper Custom BA (WiX4)1

EXEC : warning : DisplayInternalUI value of MsiPackages will be ignored because you are using custom BA. For custom BA applications visibility of the individual MSI packages needs to be controlled from the PlanMsiPackage event handler of the BA.
Read more here: #1396 (comment)


Wix project file has been built: C:\Users\A User\Documents\Support\WixSharp\1671\WixSharp Setup - Bootstrapper Custom BA (WiX4)1\setup.wxs

EXEC : error : Cannot find WiX extension 'WixToolset.Netfx.wixext'. WixSharp attempted to install the extension but did not succeed. Please install the extension manually with: wix.exe extension add -g WixToolset.Netfx.wixext
EXEC : error : Cannot find WiX extension 'WixToolset.Bal.wixext'. WixSharp attempted to install the extension but did not succeed. Please install the extension manually with: wix.exe extension add -g WixToolset.Bal.wixext
Cannot build C:\Users\A User\Documents\Support\WixSharp\1671\WixSharp Setup - Bootstrapper Custom BA (WiX4)1\setup.wxs
C:\Users\A User\Documents\Support\WixSharp\1671\WixSharp Setup - Bootstrapper Custom BA (WiX4)1\WixSharp Setup - Bootstrapper Custom BA (WiX4)1.csproj(33,5): error MSB3073: The command "cd .
C:\Users\A User\Documents\Support\WixSharp\1671\WixSharp Setup - Bootstrapper Custom BA (WiX4)1\WixSharp Setup - Bootstrapper Custom BA (WiX4)1.csproj(33,5): error MSB3073: set ide=true
C:\Users\A User\Documents\Support\WixSharp\1671\WixSharp Setup - Bootstrapper Custom BA (WiX4)1\WixSharp Setup - Bootstrapper Custom BA (WiX4)1.csproj(33,5): error MSB3073: "C:\Users\A User\Documents\Support\WixSharp\1671\WixSharp Setup - Bootstrapper Custom BA (WiX4)1\bin\Release\net472\WixSharp Setup - Bootstrapper Custom BA (WiX4)1.exe"" exited with code -1.
Done building project "WixSharp Setup - Bootstrapper Custom BA (WiX4)1.csproj" -- FAILED.

I noticed the new template is bound to WixSharp_wix4 package 2.4.2 with transitive packages WisSharp_wix4.bin 2.4.2, WixToolset.Dtf.WindowsInstaller 4.01, and WixToolset.Mba.Core 4.0.1.
Could this cause an incompatibility somehow?

@oleg-shilo
Copy link
Owner

WiX team has changed dramatically the custom BA hosting model v4->x5.
Thus I can see how all the referencing of extensions may need some renaming. But...
Somehow in my environment the old name was deploying the extension assemblies correctly:
image

I'll leave it with the WiX team. But I will update the WixSharp attempt to install the extension with the custom routine replacing the old name with the new one. Even though they may change it in the future.

I get a Hello Word message box, then default msi dialog.

I am not sure what you are running. If it is the sample from the WixSharp then it might be showing the msgbox to indicate it is a custom BA and tehn showing the msi UI to demonstrate how to display MSI UI from teh BA. It is actually very hard to achieve with teh WiX architecture.

I suggest you run that last code sample I shared in this thread. I just retested it and it does show the custom BA UI.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants