Skip to content

allow overriding Windows Wix main.wxs template #1341

@jboss48

Description

@jboss48

I had the task of generating an MSI in French while also changing the installation scope from per-machine to per-user. The default GluonFX/Substrate plugin hardcodes the MSI template (main.wxs) and the installation scope, making the task non-trivial.

Challenge
The plugin seems to copy main.wxs from its internal resources and immediately invokes WiX to build the MSI.

Solution
Forked the project to introduce configurable system properties, something like:

        var mainWxsOverride=System.getProperty("gluonfx.wix.main");
        if (mainWxsOverride!=null) {
            Path custom = Paths.get(mainWxsOverride);
            if(Files.exists(custom))
                Files.copy(custom, wixPath, REPLACE_EXISTING);
            // TODO else
        } else {
            FileOps.copyResource("/native/windows/wix/main.wxs", wixPath);
        }
  ....
        String cultureOverride=System.getProperty("gluonfx.wix.culture");
        String culture="en-us";
        if(cultureOverride!=null)
            culture=cultureOverride;
        processArgs.addAll(List.of(
                WixTool.LIGHT.getPath(),
                "-nologo",
                "-spdb",
                "-sw1076", // https://github.com/wixtoolset/issues/issues/5938
                "-ext", "WixUtilExtension",
                "-ext", "WixUIExtension",
                "-cultures:"+culture,
                "-out", msiPath.toString(),
                wixObjPath.toString()
        ));

Outcome

  • Successfully generated a French MSI with per-user installation.

  • This approach can be reused for other languages or custom MSI templates in future projects.

Conclusion
I am open to any alternative solutions or suggestions if there is a better way to handle this in the plugin or WiX configuration that I might have missed. My goal was to implement a clean, maintainable solution without relying on hacks, but I welcome feedback if there is a more efficient or standard approach.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions