Skip to content

The agent that grows with you

fix(release): provision payload signing tools on cold caches

ethernet54d6771ae998
diff --git a/apps/desktop/scripts/after-pack.mjs b/apps/desktop/scripts/after-pack.mjs
index d9589ada9f3..423e6eae8f2 100644
--- a/apps/desktop/scripts/after-pack.mjs
+++ b/apps/desktop/scripts/after-pack.mjs
@@ -86,5 +86,8 @@ export default async function afterPack(context) {
// per-file by the customSign hook (scripts/batch-sign-binaries.mjs) after
// electron-builder's own rcedit + fuses pass. No-op with a loud warning when
// the AZURE_SIGN_* environment is absent (unsigned/fork/canary lanes).
- await batchSignAppTree(context.appOutDir, exe)
+ await batchSignAppTree(context.appOutDir, exe, {
+ config: context.packager.config,
+ resourcesDir: context.packager.buildResourcesDir,
+ })
}
diff --git a/apps/desktop/scripts/batch-sign-binaries.mjs b/apps/desktop/scripts/batch-sign-binaries.mjs
index dc4b21d82cf..c1fca17593f 100644
--- a/apps/desktop/scripts/batch-sign-binaries.mjs
+++ b/apps/desktop/scripts/batch-sign-binaries.mjs
@@ -34,15 +34,15 @@
// Azure Trusted Signing variables are present (the same AZURE_SIGN_* set the
// release-signing workflow arms provide). Without them — local builds, forks,
// unsigned canary lanes — it is a no-op with a loud warning, exactly like
-// stage-msixbundle.mjs. The dlib + signtool resolution reuses the
-// electron-builder cache walk from scripts/stage-msixbundle.mjs; nothing is
-// hardcoded to C:\Tools.
+// stage-msixbundle.mjs. The shared Windows tool provisioner supplies the
+// matching SDK, ATS dlib, and .NET runtime even when the cache is empty.
import { execFile } from 'node:child_process'
import fs from 'node:fs'
import path from 'node:path'
import { isMain } from './utils.mjs'
import { createPayloadSignCache } from './payload-sign-cache.mjs'
+import { ensureWindowsBundleTools } from './windows-bundle-tools.mjs'
export const CHUNK_SIZE = 100
// How many signtool children may run at once. Azure Trusted Signing and the
@@ -169,154 +169,6 @@ export function azureSigningConfigured(env = process.env) {
return Boolean(env.AZURE_SIGN_ENDPOINT && env.AZURE_SIGN_ACCOUNT && env.AZURE_SIGN_PROFILE)
}
-// The electron-builder toolset cache roots, in precedence order — the same
-// walk scripts/stage-msixbundle.mjs does (configured ELECTRON_BUILDER_CACHE
-// beats stray defaults).
-function cacheRoots(env) {
- return [
- env.ELECTRON_BUILDER_CACHE || '',
- path.join(env.LOCALAPPDATA || '', 'electron-builder', 'Cache'),
- path.join(env.USERPROFILE || '', 'AppData', 'Local', 'electron-builder', 'Cache')
- ].filter(Boolean)
-}
-
-/**
- * Host arch for the signing toolset. The ATS bundle ships the dlib for
- * x64/x86 only (its arm64 dir has no dlib), and a 32-bit signtool cannot
- * load a 64-bit dlib — so the signtool + dlib pair must be same-arch. On
- * arm64 hosts use the x64 pair (x64 signtool runs under Windows-on-ARM
- * emulation). Mirrors app-builder-lib's WindowsSignAzureManager
- * (`process.arch === "ia32" ? Arch.ia32 : Arch.x64`).
- */
-export function signingArch() {
- return process.arch === 'ia32' ? 'x86' : 'x64'
-}
-
-/**
- * True when a resolved path sits in the `<arch>/` dir (e.g. `.../x64/signtool.exe`
- * or `.../ats-bundle-.../x64/Azure.CodeSigning.Dlib.dll`), matching both the
- * modern windows-kits-bundle layout and the legacy windows-10/<arch> layout.
- */
-function archMatch(file, arch) {
- return path.basename(path.dirname(file)).toLowerCase() === arch
-}
-
-/**
- * Find azure.codesigning.dlib.dll under the electron-builder cache, preferring
- * the one matching the host arch (x64 unless the host is ia32) so signtool can
- * load it. Returns an absolute path or null (caller decides loud-fail vs warn).
- */
-export function resolveTrustedSigningDlib(env = process.env) {
- const arch = signingArch()
- for (const root of cacheRoots(env)) {
- if (!fs.existsSync(root)) continue
- const found = []
- const walk = (p) => {
- let entries
- try {
- entries = fs.readdirSync(p, { withFileTypes: true })
- } catch {
- return
- }
- for (const entry of entries) {
- const full = path.join(p, entry.name)
- if (entry.isDirectory()) walk(full)
- else if (entry.name.toLowerCase() === 'azure.codesigning.dlib.dll') found.push(full)
- }
- }
- for (const entry of fs.readdirSync(root)) {
- walk(path.join(root, entry))
- }
- if (found.length > 0) {
- const matched = found.filter(f => archMatch(f, arch))
- const pool = matched.length > 0 ? matched : found
- pool.sort()
- return pool[pool.length - 1]
- }
- }
- return null
-}
-
-/**
- * Find a host signtool.exe under the electron-builder cache (the winCodeSign
- * toolset bundles the Windows Kits tools for arm64/x64/x86), or honor
- * SIGNTOOL_PATH. Prefers the signtool matching the host arch — a 32-bit
- * signtool cannot load the x64 ATS dlib — and among arch-matched candidates
- * the newest SDK build (sorted paths put the highest version last).
- * Returns an absolute path or null.
- */
-export function resolveSigntool(env = process.env) {
- if (env.SIGNTOOL_PATH && fs.existsSync(env.SIGNTOOL_PATH)) return env.SIGNTOOL_PATH
- const arch = signingArch()
- for (const root of cacheRoots(env)) {
- if (!fs.existsSync(root)) continue
- const found = []
- for (const entry of fs.readdirSync(root)) {
- const dir = path.join(root, entry)
- if (!fs.existsSync(dir) || !fs.statSync(dir).isDirectory()) continue
- const walk = (p, depth) => {
- if (depth > 5) return
- let entries
- try {
- entries = fs.readdirSync(p, { withFileTypes: true })
- } catch {
- return
- }
- for (const sub of entries) {
- if (sub.isSymbolicLink()) continue
- const full = path.join(p, sub.name)
- if (sub.isDirectory()) walk(full, depth + 1)
- else if (sub.name.toLowerCase() === 'signtool.exe') found.push(full)
- }
- }
- walk(dir, 0)
- }
- if (found.length > 0) {
- const matched = found.filter(f => archMatch(f, arch))
- const pool = matched.length > 0 ? matched : found
- pool.sort()
- return pool[pool.length - 1]
- }
- }
- return null
-}
-
-/**
- * Find the bundled .NET 8 runtime dir (win-codesign@&lt;ver&gt;/dotnet-runtime-*).
- * The ATS dlib is a .NET assembly loaded via Ijwhost.dll, which locates
- * hostfxr.dll through DOTNET_ROOT — without it the dlib cannot initialize even
- * with a same-arch signtool/dlib pair. Returns an absolute path or null.
- */
-export function resolveDotnetRuntimeDir(env = process.env) {
- for (const root of cacheRoots(env)) {
- if (!fs.existsSync(root)) continue
- const found = []
- const walk = (p, depth) => {
- if (depth > 3) return
- let entries
- try {
- entries = fs.readdirSync(p, { withFileTypes: true })
- } catch {
- return
- }
- for (const entry of entries) {
- if (!entry.isDirectory()) continue
- const full = path.join(p, entry.name)
- if (/^dotnet-runtime-/.test(entry.name)) found.push(full)
- else walk(full, depth + 1)
- }
- }
- for (const entry of fs.readdirSync(root)) {
- walk(path.join(root, entry), 0)
- }
- if (found.length > 0) {
- found.sort()
- return found[found.length - 1]
- }
- }
- return null
-}
-
/**
* Sign one chunk of binaries with a single signtool invocation (argv array,
* never a shell string — the joined list can be long and must not interpolate
@@ -381,7 +233,7 @@ export async function timestampChunk(files, opts) {
* passes. Identical cacheable inputs share one signing operation.
*
* @param {string[]} binaries file list from getBinaries
- * @param {{ env?: NodeJS.ProcessEnv, exec?: typeof execFile, chunkSize?: number, concurrency?: number, mkdtemp?: typeof fs.mkdtempSync, signtool?: string, dlib?: string, dotnetRoot?: string, timestampUrl?: string, timestampAttempts?: number, timestampRetryDelayMs?: number, cache?: ReturnType<typeof createPayloadSignCache> }} [opts]
+ * @param {{ env?: NodeJS.ProcessEnv, exec?: typeof execFile, chunkSize?: number, concurrency?: number, mkdtemp?: typeof fs.mkdtempSync, signtool?: string, dlib?: string, dotnetRoot?: string, config?: import('app-builder-lib').Configuration, resourcesDir?: string, timestampUrl?: string, timestampAttempts?: number, timestampRetryDelayMs?: number, cache?: ReturnType<typeof createPayloadSignCache> }} [opts]
* @returns {Promise<{ signed: number, chunks: number, skipped: boolean }>}
* skipped=true when Azure signing is not configured (caller warns).
*/
@@ -393,14 +245,10 @@ export async function batchSignBinaries(binaries, opts = {}) {
if (binaries.length === 0) {
return { signed: 0, chunks: 0, skipped: false }
}
- const dlib = opts.dlib ?? resolveTrustedSigningDlib(env)
- if (!dlib) {
- throw new Error('batch-sign-binaries: azure.codesigning.dlib.dll not found under the electron-builder cache')
- }
- const signtool = opts.signtool ?? resolveSigntool(env)
- if (!signtool) {
- throw new Error('batch-sign-binaries: signtool.exe not found under the electron-builder cache (or SIGNTOOL_PATH)')
- }
+ // afterPack runs before the per-file Azure signer downloads its tools.
+ const { signtool, dlib, dotnetRoot } = opts.signtool && opts.dlib
+ ? opts
+ : await ensureWindowsBundleTools({ signing: true, config: opts.config, resourcesDir: opts.resourcesDir })
const started = performance.now()
const cache = opts.cache === undefined ? createPayloadSignCache({
root: env.ELECTRON_BUILDER_CACHE ? `${env.ELECTRON_BUILDER_CACHE}-payload-signatures` : null,
@@ -409,12 +257,8 @@ export async function batchSignBinaries(binaries, opts = {}) {
const plan = cache ? await cache.prepare(binaries) : null
const toSign = plan?.files ?? binaries
console.log(`[batch-sign] ${plan?.restored ?? 0} cache hits, ${toSign.length} to sign, ${plan?.duplicates ?? 0} duplicate copies`)
- // The ATS dlib is a .NET assembly; Ijwhost.dll finds hostfxr.dll via
- // DOTNET_ROOT. Mirror app-builder-lib's WindowsSignAzureManager and point it
- // at the bundled runtime so the dlib initializes (a missing runtime reads as
- // "no certificates found"). Only merged when a runtime dir exists.
+ // Ijwhost.dll needs the runtime paired with the provisioned ATS dlib.
const signEnv = { ...env }
- const dotnetRoot = opts.dotnetRoot ?? resolveDotnetRuntimeDir(env)
if (dotnetRoot) signEnv.DOTNET_ROOT = dotnetRoot
const mkdtemp = opts.mkdtemp ?? fs.mkdtempSync
const tmpDir = mkdtemp(path.join(env.TEMP || env.TMP || '.', 'batch-sign-'))
@@ -458,7 +302,7 @@ export async function batchSignBinaries(binaries, opts = {}) {
*
* @param {string} appOutDir
* @param {string} productExePath absolute path of the main product exe
- * @param {{ env?: NodeJS.ProcessEnv, exec?: typeof execFile, chunkSize?: number, concurrency?: number, timestampUrl?: string, timestampAttempts?: number, timestampRetryDelayMs?: number }} [opts]
+ * @param {Parameters<typeof batchSignBinaries>[1]} [opts]
*/
export async function batchSignAppTree(appOutDir, productExePath, opts = {}) {
const env = opts.env ?? process.env
diff --git a/apps/desktop/scripts/batch-sign-binaries.test.mjs b/apps/desktop/scripts/batch-sign-binaries.test.mjs
index be17c50eb76..67ea52ad082 100644
--- a/apps/desktop/scripts/batch-sign-binaries.test.mjs
+++ b/apps/desktop/scripts/batch-sign-binaries.test.mjs
@@ -10,11 +10,7 @@ import {
batchSignAppTree,
chunk,
customSign,
- getBinaries,
- resolveDotnetRuntimeDir,
- resolveSigntool,
- resolveTrustedSigningDlib,
- signingArch
+ getBinaries
} from './batch-sign-binaries.mjs'
const tmpDirs = []
@@ -334,103 +330,32 @@ test('timestamp pass retries a flaky server before giving up', async () => {
assert.equal(calls, 3, 'timestamp pass retried until the server succeeded')
})
-// ── toolset resolution: signtool + dlib must be same-arch ───────────────────
-// The ATS bundle ships the dlib for x64/x86 only and a 32-bit signtool cannot
-// load a 64-bit dlib — resolveSigntool/resolveTrustedSigningDlib must pair the
-// HOST arch, never "whatever sorted last" (which picked x86 signtool + x64
-// dlib and broke signing with "No certificates were found"). Regression for
-// the win32-x64 release build failure.
-
-function fakeToolsetCache() {
- const cache = path.join(tmpTree(), 'electron-builder', 'Cache')
- const kits = path.join(cache, '[email protected]', 'windows-kits-bundle-10_0_26100_0-abc')
- for (const arch of ['arm64', 'x64', 'x86']) {
- fs.mkdirSync(path.join(kits, arch), { recursive: true })
- fs.writeFileSync(path.join(kits, arch, 'signtool.exe'), 'x')
- }
- const ats = path.join(cache, '[email protected]', 'ats-bundle-1_0_95-def')
- for (const arch of ['x64', 'x86']) {
- fs.mkdirSync(path.join(ats, arch), { recursive: true })
- fs.writeFileSync(path.join(ats, arch, 'Azure.CodeSigning.Dlib.dll'), 'x')
- }
- const runtime = path.join(cache, '[email protected]', 'dotnet-runtime-win-x64-8_0_28-ghi')
- fs.mkdirSync(runtime, { recursive: true })
- // Cache archives and state files must not become DOTNET_ROOT.
- fs.writeFileSync(`${runtime}.state`, '{}')
- fs.writeFileSync(path.join(path.dirname(runtime), 'dotnet-runtime-win-x64-8_0_28.zip'), 'archive')
- return { cache, kits, ats }
-}
-
-test('signingArch matches the host (x64 unless ia32)', () => {
- assert.equal(signingArch(), process.arch === 'ia32' ? 'x86' : 'x64')
-})
-
-test('resolveSigntool prefers the host-arch kit over x86', () => {
- const { cache } = fakeToolsetCache()
- const signtool = resolveSigntool({ ELECTRON_BUILDER_CACHE: cache })
- const expectedArch = signingArch()
- assert.ok(signtool, 'a signtool must resolve from the fake cache')
- assert.ok(
- signtool.toLowerCase().includes(`\\${expectedArch}\\signtool.exe`) ||
- signtool.toLowerCase().includes(`/${expectedArch}/signtool.exe`),
- `expected the ${expectedArch} signtool, got ${signtool}`
- )
-})
-
-test('resolveTrustedSigningDlib prefers the host-arch dlib over x86', () => {
- const { cache } = fakeToolsetCache()
- const dlib = resolveTrustedSigningDlib({ ELECTRON_BUILDER_CACHE: cache })
- const expectedArch = signingArch()
- assert.ok(dlib, 'a dlib must resolve from the fake cache')
- assert.ok(
- dlib.toLowerCase().includes(`\\${expectedArch}\\azure.codesigning.dlib.dll`) ||
- dlib.toLowerCase().includes(`/${expectedArch}/azure.codesigning.dlib.dll`),
- `expected the ${expectedArch} dlib, got ${dlib}`
- )
-})
-
-test('resolveDotnetRuntimeDir finds the bundled .NET runtime dir', () => {
- const { cache } = fakeToolsetCache()
- const dotnet = resolveDotnetRuntimeDir({ ELECTRON_BUILDER_CACHE: cache })
- assert.ok(dotnet, 'the dotnet-runtime bundle must resolve')
- assert.ok(/dotnet-runtime-/.test(path.basename(dotnet)), `unexpected dotnet dir ${dotnet}`)
-})
-
-test('batchSignBinaries sets DOTNET_ROOT from the bundled runtime for the signtool child', async () => {
- const { cache } = fakeToolsetCache()
+test('batch signing passes its paired toolchain and runtime to both child phases', async () => {
const root = tmpTree()
- fs.mkdirSync(path.join(root, 'tools'), { recursive: true })
- fs.writeFileSync(path.join(root, 'tools', 'node.exe'), 'x')
- const exe = path.join(root, 'Hermes.exe')
-
+ fs.writeFileSync(path.join(root, 'node.exe'), 'x')
+ const tools = {
+ signtool: path.join(root, 'SDK with spaces', 'signtool.exe'),
+ dlib: path.join(root, 'ATS with spaces', 'Azure.CodeSigning.Dlib.dll'),
+ dotnetRoot: path.join(root, 'dotnet'),
+ }
const invocations = []
- const result = await batchSignAppTree(root, exe, {
+ const result = await batchSignAppTree(root, path.join(root, 'Hermes.exe'), {
+ ...tools,
env: {
- ELECTRON_BUILDER_CACHE: cache,
- AZURE_SIGN_ENDPOINT: 'https://cus.codesigning.azure.net',
- AZURE_SIGN_ACCOUNT: 'codesign2',
- AZURE_SIGN_PROFILE: 'hermesagent'
+ AZURE_SIGN_ENDPOINT: 'https://test.invalid',
+ AZURE_SIGN_ACCOUNT: 'account', AZURE_SIGN_PROFILE: 'profile',
+ DOTNET_ROOT: 'unrelated machine runtime', TEMP: root,
},
- exec: (tool, args, opts) => {
- invocations.push({ tool, args, opts })
- return Buffer.from('')
- },
- mkdtemp: () => root
+ exec: (tool, args, options) => { invocations.push({ tool, args, options }) },
+ cache: null,
})
-
assert.equal(result.signed, 1)
- assert.equal(invocations.length, 2, 'one sign + one timestamp pass')
- const signInv = invocations.find(inv => inv.args[0] === 'sign')
- const tsInv = invocations.find(inv => inv.args[0] === 'timestamp')
- assert.ok(signInv, 'sign pass present')
- assert.ok(tsInv, 'timestamp pass present')
- const opts = signInv.opts
- assert.ok(opts && opts.env, 'exec must receive a child env')
- assert.equal(opts.env.DOTNET_ROOT, path.join(cache, '[email protected]', 'dotnet-runtime-win-x64-8_0_28-ghi'))
- // The signtool chosen must be the host-arch one, not x86.
- assert.match(signInv.tool, new RegExp(`[\\\\/]${signingArch()}[\\\\/]signtool\\.exe$`))
- assert.match(tsInv.tool, new RegExp(`[\\\\/]${signingArch()}[\\\\/]signtool\\.exe$`))
- const dlibArg = signInv.args[signInv.args.indexOf('/dlib') + 1]
- assert.match(dlibArg, new RegExp(`[\\\\/]${signingArch()}[\\\\/]azure\\.codesigning\\.dlib\\.dll$`, 'i'))
- assert.equal(tsInv.args.includes('/dlib'), false, 'timestamp pass has no dlib')
+ assert.deepEqual(invocations.map(call => call.args[0]), ['sign', 'timestamp'])
+ for (const call of invocations) {
+ assert.equal(call.tool, tools.signtool)
+ assert.equal(call.options.env.DOTNET_ROOT, tools.dotnetRoot)
+ }
+ const [sign, timestamp] = invocations
+ assert.equal(sign.args[sign.args.indexOf('/dlib') + 1], tools.dlib)
+ assert.equal(timestamp.args.includes('/dlib'), false)
})
diff --git a/apps/desktop/scripts/payload-sign-cache.test.mjs b/apps/desktop/scripts/payload-sign-cache.test.mjs
index 6dc02c28950..ade8b267723 100644
--- a/apps/desktop/scripts/payload-sign-cache.test.mjs
+++ b/apps/desktop/scripts/payload-sign-cache.test.mjs
@@ -4,13 +4,11 @@ import os from 'node:os'
import path from 'node:path'
import { execFileSync } from 'node:child_process'
import { expect, test, vi } from 'vitest'
-import { batchSignBinaries, resolveSigntool } from './batch-sign-binaries.mjs'
+import { batchSignBinaries } from './batch-sign-binaries.mjs'
+import { ensureWindowsBundleTools } from './windows-bundle-tools.mjs'
import { createPayloadSignCache, peContentHash, verifySignedPayloads } from './payload-sign-cache.mjs'
import { readSecurityDirectory } from './sanitize-pe-signatures.mjs'
-// The release builder installs this SDK before it runs the native signing tests.
-const nativeSigntool = process.platform === 'win32' ? resolveSigntool() : null
-
const hash = bytes => createHash('sha256').update(bytes).digest('hex')
// Minimal PE input for byte-binding tests, not a signature-validity fixture.
@@ -73,9 +71,11 @@ test.runIf(process.platform === 'win32')('native verification binds cached bytes
} finally { f.cleanup() }
}, 30000)
-test.runIf(process.platform === 'win32' && nativeSigntool)('catalog trust cannot mask the embedded signature', async () => {
+test.runIf(process.platform === 'win32')('catalog trust cannot mask the embedded signature', async () => {
const f = fixture()
+ vi.stubEnv('ELECTRON_BUILDER_CACHE', path.join(f.root, 'sdk-cache'))
try {
+ const { signtool: nativeSigntool } = await ensureWindowsBundleTools()
const source = path.join(process.env.SystemRoot, 'System32', 'kernel32.dll')
const publisher = execFileSync('powershell.exe', ['-NoProfile', '-NonInteractive', '-Command',
'[Security.Cryptography.X509Certificates.X509Certificate]::CreateFromSignedFile($env:NATIVE_SIGN_TEST_INPUT).Subject'
@@ -103,8 +103,11 @@ test.runIf(process.platform === 'win32' && nativeSigntool)('catalog trust cannot
execFileSync(nativeSigntool, ['remove', '/u', files[1]], { windowsHide: true })
expect(catalog()).toEqual({ Status: 'Valid', Type: 'Catalog' })
expect(await verifySignedPayloads(files, publisher, nativeSigntool)).toEqual(new Set([files[0]]))
- } finally { f.cleanup() }
-}, 60000)
+ } finally {
+ vi.unstubAllEnvs()
+ f.cleanup()
+ }
+}, 240000)
test('input bytes select entries across paths, while policy and executable content stay binding', async () => {
const f = fixture()
diff --git a/apps/desktop/scripts/windows-bundle-tools.test.mjs b/apps/desktop/scripts/windows-bundle-tools.test.mjs
index 39d94d5d3f7..c4ed48e390b 100644
--- a/apps/desktop/scripts/windows-bundle-tools.test.mjs
+++ b/apps/desktop/scripts/windows-bundle-tools.test.mjs
@@ -4,6 +4,7 @@ import os from 'node:os'
import path from 'node:path'
import { afterEach, expect, test, vi } from 'vitest'
import { ensureWindowsBundleTools } from './windows-bundle-tools.mjs'
+import { batchSignAppTree } from './batch-sign-binaries.mjs'
const directories = []
afterEach(() => {
@@ -57,13 +58,39 @@ test('both bundle modes provision pinned tools rather than search a prefilled ca
await expect(ensureWindowsBundleTools({ load: async () => ({ ...builder, getWindowsKitsBundle: failed }), config: {}, resourcesDir })).rejects.toThrow('pinned download failed')
})
-test.runIf(process.platform === 'win32')('a native cold install produces executable SDK tools and reuses them warm', { timeout: 240_000 }, async () => {
+test.runIf(process.platform === 'win32')('a cold payload signer provisions executable SDK tools and reuses them warm', { timeout: 240_000 }, async () => {
const root = fs.mkdtempSync(path.join(os.tmpdir(), 'bundle-tools-native-'))
directories.push(root)
const previous = process.env.ELECTRON_BUILDER_CACHE
process.env.ELECTRON_BUILDER_CACHE = path.join(root, 'empty-cache')
try {
+ const app = path.join(root, 'app')
+ fs.mkdirSync(app)
+ const binary = path.join(app, 'payload.exe')
+ fs.copyFileSync(process.execPath, binary)
+ const signingBoundary = new Error('signing boundary reached')
+ let requested
+ // Stop before Azure. Downloads and SDK execution below are real.
+ await expect(batchSignAppTree(app, path.join(app, 'Hermes.exe'), {
+ env: {
+ ELECTRON_BUILDER_CACHE: process.env.ELECTRON_BUILDER_CACHE,
+ LOCALAPPDATA: root, USERPROFILE: root, TEMP: root,
+ AZURE_SIGN_ENDPOINT: 'https://test.invalid',
+ AZURE_SIGN_ACCOUNT: 'account', AZURE_SIGN_PROFILE: 'profile',
+ },
+ cache: null,
+ exec: async (signtool, args, options) => {
+ expect(args[0]).toBe('sign')
+ expect(args).toContain(binary)
+ requested = {
+ signtool, dlib: args[args.indexOf('/dlib') + 1],
+ dotnetRoot: options.env.DOTNET_ROOT,
+ }
+ throw signingBoundary
+ },
+ })).rejects.toBe(signingBoundary)
const tools = await ensureWindowsBundleTools({ signing: true })
+ expect(requested).toEqual({ signtool: tools.signtool, dlib: tools.dlib, dotnetRoot: tools.dotnetRoot })
for (const file of [tools.makeappx, tools.signtool, tools.dlib, tools.dotnetRoot]) {
expect(path.relative(root, file).startsWith('..')).toBe(false)
}