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

feat(nsis): allow disabling of building a universal installer #8607

Open
wants to merge 17 commits into
base: master
Choose a base branch
from

Conversation

mmaietta
Copy link
Collaborator

By default, electron-builder builds a universal NSIS package when multiple archs are specified. This universal exe size is usually the sum of each individual installer.

This PR introduces a config property buildUniversalInstaller (default true for backward compatibility)
In order to build separate exe's, I needed to update the installer name template to include an arch. Unless a defaultArch is supplied, x64 will not have a suffix appended to the file name and the other arch builds will have suffix -${arch}.

protected installerFilenamePattern(primaryArch?: Arch | null, defaultArch?: string): string {
if (!this.shouldBuildUniversalInstaller()) {
return "${productName} " + (this.isPortable ? "" : "Setup ") + "${version}" + (primaryArch != null ? getArchSuffix(primaryArch, defaultArch) : "") + ".${ext}"
}
// tslint:disable:no-invalid-template-strings
return "${productName} " + (this.isPortable ? "" : "Setup ") + "${version}.${ext}"
}

Note: Only nsis targets supports individual installers as nsis-web requires 32 bit arch to be present in the distributable package since it automatically detects OS architecture and downloads the corresponding package file. nsis-web logic overrides any setting to buildUniversalInstaller to true.
Ref: https://www.electron.build/nsis.html#web-installer

Resolves: #8298 and #8597

Copy link

changeset-bot bot commented Oct 17, 2024

🦋 Changeset detected

Latest commit: b5914a3

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 8 packages
Name Type
app-builder-lib Major
dmg-builder Major
electron-builder-squirrel-windows Major
electron-builder Major
electron-forge-maker-appimage Major
electron-forge-maker-nsis-web Major
electron-forge-maker-nsis Major
electron-forge-maker-snap Major

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

netlify bot commented Oct 17, 2024

Deploy Preview for car-park-attendant-cleat-11576 ready!

Name Link
🔨 Latest commit b5914a3
🔍 Latest deploy log https://app.netlify.com/sites/car-park-attendant-cleat-11576/deploys/67152597c730880008e878de
😎 Deploy Preview https://deploy-preview-8607--car-park-attendant-cleat-11576.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@mmaietta mmaietta linked an issue Oct 17, 2024 that may be closed by this pull request
@mmaietta mmaietta marked this pull request as ready for review October 17, 2024 15:59
protected buildUniversalInstaller() {
const buildSeparateInstallers = this.options.buildUniversalInstaller === false
return !buildSeparateInstallers
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

protected buildUniversalInstaller() {
    return this.options.buildUniversalInstaller 
 }

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

buildUniversalInstaller is optional, so we must check against explicit false.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not a get function, so there shouldn't be any caching, right?

protected installerFilenamePattern(primaryArch?: Arch | null, defaultArch?: string): string {
if (!this.buildUniversalInstaller()) {
return "${productName} " + (this.isPortable ? "" : "Setup ") + "${version}" + (primaryArch != null ? getArchSuffix(primaryArch, defaultArch) : "") + ".${ext}"
}
// tslint:disable:no-invalid-template-strings
return "${productName} " + (this.isPortable ? "" : "Setup ") + "${version}.${ext}"
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

protected installerFilenamePattern(primaryArch?: Arch | null, defaultArch?: string): string {
  const setupText = this.isPortable ? "" : "Setup ";
  const archSuffix = !this.buildUniversalInstaller() && primaryArch != null 
    ? getArchSuffix(primaryArch, defaultArch) 
    : "";
  
  return "${productName} " + setupText + "${version}" + archSuffix + ".${ext}";
}

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love it, I'll update the logic.

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