PyOxidizer icon indicating copy to clipboard operation
PyOxidizer copied to clipboard

Adding own wix xml (.wxs) file to project

Open henningWoehr opened this issue 3 years ago • 5 comments

Hi, I'm currently trying to use the wix toolset together with pyoxidizer to build an msi-installer, which installs the application as a service on windows. To accomplish that, I'm trying to add additional xml code to the automatic-generated wix config. In the docs, there is the following statement:

Note that it is possible to use one of the higher-level interfaces for automatically generating a .wxs file and then supplement this automatically-generated file with other .wxs files that you maintain.

That's exactly how I want to use the wix-toolset, because I don't want to write all of the wix code and just add that, what I need. Currently I'm only able to add an .wxs file to the build environment, but can't figure out, what to write inside the .wxs file, because what I read is, that normally, to use multiple files with wix, you have to reference the "outsourced" code with something like "ComponentRef" etc., but since the main.wxs is autogenerated, I couldn't find any solution for this.

This is the code, where I specify, which .wxs file to import into the build process:

def make_msi(exe):
# See the full docs for more. But this will convert your Python executable
    # into a `WiXMSIBuilder` Starlark type, which will be converted to a Windows
    # .msi installer when it is built.
    
    wix_installer = WiXInstaller("service2", "Service.msi")

    wix_msi_builder = exe.to_wix_msi_builder(
        # Simple identifier of your app.
        "my_service",
        # The name of your application.
        "My Service",
        # The version of your application.
        "0.1.0",
        # The author/manufacturer of your application.
        "Henning Wöhrmann"
    )

    # wix_msi_builder.dialog_bmp_path = "graphics/dialog.bmp"

    wix_installer.add_build_file("graphics/dialog.bmp", "graphics/dialog.bmp")

    wix_installer.add_msi_builder(wix_msi_builder)
    wix_installer.add_wxs_file("serviceConfig2.wxs")

    return wix_installer

I hope my issue is understandable and someone can help me with this.

henningWoehr avatar Sep 26 '22 13:09 henningWoehr

Hello, I'm also interested in adding additional / custom wxs XML to the auto-generated project, did you ever have success with this yourself?

andrewleech avatar Jul 04 '23 11:07 andrewleech

No I never got this to work

henningWoehr avatar Jul 04 '23 11:07 henningWoehr

Thanks, I'll let you know if I make any progress myself

andrewleech avatar Jul 04 '23 11:07 andrewleech

I'll add that I also don't see how this would work.

I suppose that the intention is to not use the add_msi_builder at all when using add_wxs_file. In that case, one could use the main.wxs generated by a previous run, edited as required. But then I'm not sure how to get the install-files.wxs and any other required magic?

JPHutchins avatar Feb 29 '24 08:02 JPHutchins

I see something of a resolution by using the to_file_manifest function:

def make_msi(exe):
    installer = WiXInstaller("app", "app.msi")
    installer.add_wxs_file("windows/main.wxs")
    installer.add_install_files(exe.to_file_manifest("."))

    return installer

But TBH I am afraid for long term support so I'm going to switch back to PyInstaller and try to generate the wxs files from simple python scripts. I like the idea here, but there are so many abstraction layers and automations that it feels a bit inflexible for anything but the simplest apps.

JPHutchins avatar Feb 29 '24 20:02 JPHutchins