Repository: electron-userland/electron-builder
File: packages/app-builder-lib/src/targets/MsiTarget.ts (TypeScript)

Code before:
  }

  protected get upgradeCode(): string {
    return (this.options.upgradeCode || UUID.v5(this.packager.appInfo.id, ELECTRON_BUILDER_UPGRADE_CODE_NS_UUID)).toUpperCase()
  }

  async build(appOutDir: string, arch: Arch) {
    const packager = this.packager
    const artifactName = packager.expandArtifactBeautyNamePattern(this.options, "msi", arch)
    const artifactPath = path.join(this.outDir, artifactName)
    await packager.info.callArtifactBuildStarted({
      targetPresentableName: "MSI",
      file: artifactPath,
      arch,
    })

    const stageDir = await createStageDir(this, packager, arch)
    const vm = this.vm

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

    // wix 4.0.0.5512.2 doesn't support the arm64 architecture so default to x64 when building for arm64.
    // This will result in an x64 MSI installer that installs an arm64 version of the application. This is a
    // stopgap until the electron-builder-binaries wix version is upgraded to a version that supports arm64.
    const wixArch = arch == Arch.arm64 ? Arch.x64 : arch;

    const projectFile = stageDir.getTempFile("project.wxs")
    const objectFiles = ["project.wixobj"]
    await writeFile(projectFile, await this.writeManifest(appOutDir, wixArch, commonOptions))

    await packager.info.callMsiProjectCreated(projectFile)

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

    // noinspection SpellCheckingInspection
    const candleArgs = ["-arch", wixArch === Arch.ia32 ? "x86" : "x64", `-dappDir=${vm.toVmFile(appOutDir)}`].concat(this.getCommonWixArgs())
    candleArgs.push("project.wxs")
    await vm.exec(vm.toVmFile(path.join(vendorPath, "candle.exe")), candleArgs, {
      cwd: stageDir.dir,
    })

    await this.light(objectFiles, vm, artifactPath, appOutDir, vendorPath, stageDir.dir)

    await stageDir.cleanup()

    await packager.sign(artifactPath)

    await packager.info.callArtifactBuildCompleted({
      file: artifactPath,
      packager,

Review comment (suggestion):
Thanks for the detailed comment! Would you mind also adding this line to the comment just so that it's easier to track when we can upgrade?
`// https://github.com/electron-userland/electron-builder/issues/6077`

Code after:
  }

  protected get upgradeCode(): string {
    return (this.options.upgradeCode || UUID.v5(this.packager.appInfo.id, ELECTRON_BUILDER_UPGRADE_CODE_NS_UUID)).toUpperCase()
  }

  async build(appOutDir: string, arch: Arch) {
    const packager = this.packager
    const artifactName = packager.expandArtifactBeautyNamePattern(this.options, "msi", arch)
    const artifactPath = path.join(this.outDir, artifactName)
    await packager.info.callArtifactBuildStarted({
      targetPresentableName: "MSI",
      file: artifactPath,
      arch,
    })

    const stageDir = await createStageDir(this, packager, arch)
    const vm = this.vm

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

    // wix 4.0.0.5512.2 doesn't support the arm64 architecture so default to x64 when building for arm64.
    // This will result in an x64 MSI installer that installs an arm64 version of the application. This is a
    // stopgap until the electron-builder-binaries wix version is upgraded to a version that supports arm64:
    // https://github.com/electron-userland/electron-builder/issues/6077
    const wixArch = arch == Arch.arm64 ? Arch.x64 : arch;

    const projectFile = stageDir.getTempFile("project.wxs")
    const objectFiles = ["project.wixobj"]
    await writeFile(projectFile, await this.writeManifest(appOutDir, wixArch, commonOptions))

    await packager.info.callMsiProjectCreated(projectFile)

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

    // noinspection SpellCheckingInspection
    const candleArgs = ["-arch", wixArch === Arch.ia32 ? "x86" : "x64", `-dappDir=${vm.toVmFile(appOutDir)}`].concat(this.getCommonWixArgs())
    candleArgs.push("project.wxs")
    await vm.exec(vm.toVmFile(path.join(vendorPath, "candle.exe")), candleArgs, {
      cwd: stageDir.dir,
    })

    await this.light(objectFiles, vm, artifactPath, appOutDir, vendorPath, stageDir.dir)

    await stageDir.cleanup()

    await packager.sign(artifactPath)

    await packager.info.callArtifactBuildCompleted({
      file: artifactPath,