electron-userland / electron-builder

A complete solution to package and build a ready for distribution Electron app with “auto update” support out of the box
https://www.electron.build
MIT License
13.51k stars 1.73k forks source link

Option to Disable Combined NSIS Installer When Building for Multiple Architectures #8298

Open PeterDaveHello opened 4 weeks ago

PeterDaveHello commented 4 weeks ago

When building for both 32-bit and 64-bit architectures, Electron Builder creates separate installers for each architecture as well as a combined installer. Is there an option to disable the creation of this combined installer?

Currently, I can't find a way on the doc(https://www.electron.build/configuration/nsis#32-bit-64-bit) to only generate the separate 32-bit and 64-bit installers without also producing the combined one. It would be helpful to have an option like nsis.disableCombinedInstaller: true or nsis.enableCombinedInstaller: false to prevent the creation of the combined installer when it's not needed.

Thank you for your assistance.

PeterDaveHello commented 4 weeks ago

It seems this feature doesn't just work on 32-bit(x86/ia32) + 64-bit(amd64), as the doc mentioned, but also on arm64+amd64, arm64+amd64+ia32, and maybe other combinations.

These are the screenshots from using 7-zip to open the $PLUGINSDIR\ folder in the NSIS installers in different combinations:

image

image

mmaietta commented 4 weeks ago

So I must admit I don't have the original insight as to why the installers are always combined. I had a project in the past where it was required to have two distinct installers, one for each bitness, though and I implemented an electron-builder script using the programmatic API. I think it looked something akin to the code below (just make sure your artifact name uses the {arch} macro so that the second build command doesn't overwrite the artifact of the first one.) https://www.electron.build/api/programmatic-usage

await builder.build({
  targets: platform.createTarget("nsis", 'x64')
  config: options
})
await builder.build({
  targets: platform.createTarget("nsis", 'ia32')
  config: options
})
PeterDaveHello commented 4 weeks ago

Sure we can do it by different approach like using command line to build them separately, but a simple option would be also nice 😄

mmaietta commented 3 weeks ago

Can you share your electron-builder config?

Try this win config for your electron-builder configuration. I was able to build separate installers for x64 and arm64 in this manner.

win: {
        target: [
            {
                target: 'nsis',
                arch: 'x64'
            },
            {
                target: 'nsis',
                arch: 'arm64'
            }
        ],  
}
Screenshot 2024-07-11 at 11 35 11 AM