diff --git a/scripts/build-desktop-artifact.test.ts b/scripts/build-desktop-artifact.test.ts index c9180ec3d3ae6..7be62014410af 100644 --- a/scripts/build-desktop-artifact.test.ts +++ b/scripts/build-desktop-artifact.test.ts @@ -986,6 +986,20 @@ it.layer(NodeServices.layer)("build-desktop-artifact", (it) => { assert.deepStrictEqual(result.unpackedFiles, ["node_modules/native/addon.node"]); assert.isBelow(result.fileCount, WINDOWS_PACKAGED_PAYLOAD_FILE_LIMIT); assert.deepStrictEqual(secondAsar, firstAsar); + + const compileCacheDir = path.join(fixture.packagedAppDir, "resources/server-compile-cache"); + yield* fs.makeDirectory(compileCacheDir, { recursive: true }); + for (const name of ["manifest.json", "0016a2bb", "0736d3e0"]) { + yield* fs.writeFileString(path.join(compileCacheDir, name), "cache"); + } + const withCache = yield* validateWindowsPackagedPayload({ + stageDistDir: fixture.stageDistDir, + appExecutableName: fixture.appExecutableName, + targetArch: "x64", + appVersion: WINDOWS_PAYLOAD_FIXTURE_VERSION, + fileLimit: result.fileCount, + }); + assert.equal(withCache.fileCount, result.fileCount); }), ).pipe(Effect.provideService(HostProcess.Platform, "linux")), ); diff --git a/scripts/build-desktop-artifact.ts b/scripts/build-desktop-artifact.ts index 0063a672e84a5..36baafdedb92e 100644 --- a/scripts/build-desktop-artifact.ts +++ b/scripts/build-desktop-artifact.ts @@ -1062,8 +1062,10 @@ export function resolveWindowsServerAsarIgnoreGlobs(arch: typeof BuildArch.Type) ]; } -// Fork: 110, not upstream's 80. Fork natives add 15 files and a native Windows build adds the server compile cache. -export const WINDOWS_PACKAGED_PAYLOAD_FILE_LIMIT = 110; +// Fork: 95, not upstream's 80, for 15 fork natives. Upstream cross-builds Windows without the +// server compile cache, which grows with every server chunk, so the count leaves it out. +export const WINDOWS_PACKAGED_PAYLOAD_FILE_LIMIT = 95; +const WINDOWS_PAYLOAD_UNCOUNTED_DIR = "resources/server-compile-cache"; export const WINDOWS_SERVER_RESOURCE_SOURCE_DIR = "apps/desktop/prod-resources/windows-server"; export const WINDOWS_SERVER_EXTRA_RESOURCES = [ { @@ -3204,6 +3206,7 @@ function collectUnpackedAsarFiles( const countPayloadFiles = Effect.fn("desktopArtifact.countPayloadFiles")(function* (root: string) { const fs = yield* FileSystem.FileSystem; const path = yield* Path.Path; + const uncounted = path.join(root, ...WINDOWS_PAYLOAD_UNCOUNTED_DIR.split("/")); const pendingDirectories = [root]; let count = 0; @@ -3215,7 +3218,7 @@ const countPayloadFiles = Effect.fn("desktopArtifact.countPayloadFiles")(functio const entryPath = path.join(directory, entry); const stat = yield* fs.stat(entryPath); if (stat.type === "Directory") { - pendingDirectories.push(entryPath); + if (entryPath !== uncounted) pendingDirectories.push(entryPath); } else if (stat.type === "File") { count += 1; }