Skip to content

Commit e6f1beb

Browse files
authored
feat(msi): build emulated arm64 MSI installers (#8086)
Build x64 MSI installers when targeting the arm64 architecture. This results in an x64 MSI installer that installs an arm64 version of the application. An x64 MSI installer is an improvement because building arm64 MSI targets errors with: ``` error CNDL0264 : The parameter 'arch' is missing or has an invalid value arm64. Possible values are x86, x64, or ia64. ``` This is a stopgap until the electron-builder-binaries wix version is upgraded to a version that supports arm64 which is currently blocked by a number of breaking changes between 4.0.0.5512.2 and 4.0.1. This upgrade is discussed in #6077.
1 parent 79df542 commit e6f1beb

2 files changed

Lines changed: 15 additions & 4 deletions

File tree

.changeset/chatty-dolphins-poke.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"app-builder-lib": minor
3+
---
4+
5+
feat(msi): build emulated arm64 MSI installers

packages/app-builder-lib/src/targets/MsiTarget.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,17 +75,23 @@ export default class MsiTarget extends Target {
7575

7676
const commonOptions = getEffectiveOptions(this.options, this.packager)
7777

78+
// wix 4.0.0.5512.2 doesn't support the arm64 architecture so default to x64 when building for arm64.
79+
// This will result in an x64 MSI installer that installs an arm64 version of the application. This is a
80+
// stopgap until the electron-builder-binaries wix version is upgraded to a version that supports arm64:
81+
// https://github.com/electron-userland/electron-builder/issues/6077
82+
const wixArch = arch == Arch.arm64 ? Arch.x64 : arch;
83+
7884
const projectFile = stageDir.getTempFile("project.wxs")
7985
const objectFiles = ["project.wixobj"]
80-
await writeFile(projectFile, await this.writeManifest(appOutDir, arch, commonOptions))
86+
await writeFile(projectFile, await this.writeManifest(appOutDir, wixArch, commonOptions))
8187

8288
await packager.info.callMsiProjectCreated(projectFile)
8389

8490
// noinspection SpellCheckingInspection
8591
const vendorPath = await getBinFromUrl("wix", "4.0.0.5512.2", "/X5poahdCc3199Vt6AP7gluTlT1nxi9cbbHhZhCMEu+ngyP1LiBMn+oZX7QAZVaKeBMc2SjVp7fJqNLqsUnPNQ==")
8692

8793
// noinspection SpellCheckingInspection
88-
const candleArgs = ["-arch", arch === Arch.ia32 ? "x86" : arch === Arch.arm64 ? "arm64" : "x64", `-dappDir=${vm.toVmFile(appOutDir)}`].concat(this.getCommonWixArgs())
94+
const candleArgs = ["-arch", wixArch === Arch.ia32 ? "x86" : "x64", `-dappDir=${vm.toVmFile(appOutDir)}`].concat(this.getCommonWixArgs())
8995
candleArgs.push("project.wxs")
9096
await vm.exec(vm.toVmFile(path.join(vendorPath, "candle.exe")), candleArgs, {
9197
cwd: stageDir.dir,
@@ -150,7 +156,7 @@ export default class MsiTarget extends Target {
150156
return args
151157
}
152158

153-
protected async writeManifest(appOutDir: string, arch: Arch, commonOptions: FinalCommonWindowsInstallerOptions) {
159+
protected async writeManifest(appOutDir: string, wixArch: Arch, commonOptions: FinalCommonWindowsInstallerOptions) {
154160
const appInfo = this.packager.appInfo
155161
const { files, dirs } = await this.computeFileDeclaration(appOutDir)
156162
const options = this.options
@@ -160,7 +166,7 @@ export default class MsiTarget extends Target {
160166
isCreateDesktopShortcut: commonOptions.isCreateDesktopShortcut !== DesktopShortcutCreationPolicy.NEVER,
161167
isRunAfterFinish: options.runAfterFinish !== false,
162168
// https://stackoverflow.com/questions/1929038/compilation-error-ice80-the-64bitcomponent-uses-32bitdirectory
163-
programFilesId: arch === Arch.x64 ? "ProgramFiles64Folder" : "ProgramFilesFolder",
169+
programFilesId: wixArch === Arch.x64 ? "ProgramFiles64Folder" : "ProgramFilesFolder",
164170
// wix in the name because special wix format can be used in the name
165171
installationDirectoryWixName: getWindowsInstallationDirName(appInfo, commonOptions.isAssisted || commonOptions.isPerMachine === true),
166172
dirs,

0 commit comments

Comments
 (0)