close
Skip to content

Commit 02a9105

Browse files
authored
fix(win): rebuild app exe if header of the asar has changed (#9607)
1 parent 4e83aeb commit 02a9105

2 files changed

Lines changed: 16 additions & 3 deletions

File tree

‎.changeset/wild-zebras-cheat.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"app-builder-lib": patch
3+
---
4+
5+
fix(win): regenerate app exe if header of the asar has changed so that asar integrity properly matches

‎packages/app-builder-lib/src/winPackager.ts‎

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
import { Arch, CopyFileTransformer, executeAppBuilder, FileTransformer, InvalidConfigurationError, log, use, walk } from "builder-util"
1+
import { Arch, CopyFileTransformer, executeAppBuilder, exists, FileTransformer, InvalidConfigurationError, log, use, walk } from "builder-util"
22
import { Nullish } from "builder-util-runtime"
3+
import { isCI } from "ci-info"
34
import { createHash } from "crypto"
45
import { readdir } from "fs/promises"
5-
import { isCI } from "ci-info"
66
import { Lazy } from "lazy-val"
77
import * as path from "path"
8+
import { readAsarHeader } from "./asar/asar"
89
import { SignManager } from "./codeSign/signManager"
910
import { signWindows, WindowsSignOptions } from "./codeSign/windowsCodeSign"
1011
import { WindowsSignAzureManager } from "./codeSign/windowsSignAzureManager"
@@ -21,12 +22,12 @@ import { NsisTarget } from "./targets/nsis/NsisTarget"
2122
import { AppPackageHelper, CopyElevateHelper } from "./targets/nsis/nsisUtil"
2223
import { WebInstallerTarget } from "./targets/nsis/WebInstallerTarget"
2324
import { createCommonTarget } from "./targets/targetFactory"
25+
import { getRceditBundle } from "./toolsets/windows"
2426
import { BuildCacheManager, digest } from "./util/cacheManager"
2527
import { isBuildCacheEnabled } from "./util/flags"
2628
import { time } from "./util/timer"
2729
import { getWindowsVm, VmManager } from "./vm/vm"
2830
import { execWine } from "./wine"
29-
import { getRceditBundle } from "./toolsets/windows"
3031

3132
export class WinPackager extends PlatformPackager<WindowsConfiguration> {
3233
_iconPath = new Lazy(() => this.getOrConvertIcon("ico"))
@@ -203,6 +204,13 @@ export class WinPackager extends PlatformPackager<WindowsConfiguration> {
203204
hash.update(this.platformSpecificBuildOptions.signtoolOptions?.certificateSha1 || "no certificateSha1")
204205
hash.update(this.platformSpecificBuildOptions.signtoolOptions?.certificateSubjectName || "no subjectName")
205206

207+
const asar = path.resolve(this.getResourcesDir(outDir), "app.asar")
208+
if (await exists(asar)) {
209+
hash.update((await readAsarHeader(asar)).header)
210+
} else {
211+
hash.update("no asar")
212+
}
213+
206214
buildCacheManager = new BuildCacheManager(outDir, file, arch)
207215
if (await buildCacheManager.copyIfValid(await digest(hash, files))) {
208216
timer.end()

0 commit comments

Comments
 (0)