diff --git a/docs/Options.md b/docs/Options.md
index b302c8467a0..a0f41dbfb7a 100644
--- a/docs/Options.md
+++ b/docs/Options.md
@@ -253,6 +253,7 @@ Configuration Options
* `artifactName` String - The [artifact file name pattern](https://github.com/electron-userland/electron-builder/wiki/Options#artifact-file-name-pattern). Defaults to `${productName} Setup ${version}.${ext}`.
* `unicode` = `true` Boolean - Whether to create [Unicode installer](http://nsis.sourceforge.net/Docs/Chapter1.html#intro-unicode).
* `deleteAppDataOnUninstall` = `false` Boolean - *one-click installer only.* Whether to delete app data on uninstall.
+ * `doNotPackElevateHelper` = `false` Boolean - Whether to pack the elevate executable.
* `nsisWeb` - Web Installer specific options.
* `appPackageUrl` String - The application package download URL. Optional — by default computed using publish configuration.
@@ -341,4 +342,4 @@ Some standard fields should be defined in the `package.json`.
## Build Version Management
-`CFBundleVersion` (macOS) and `FileVersion` (Windows) will be set automatically to `version.build_number` on CI server (Travis, AppVeyor, CircleCI and Bamboo supported).
\ No newline at end of file
+`CFBundleVersion` (macOS) and `FileVersion` (Windows) will be set automatically to `version.build_number` on CI server (Travis, AppVeyor, CircleCI and Bamboo supported).
diff --git a/packages/electron-builder/src/options/winOptions.ts b/packages/electron-builder/src/options/winOptions.ts
index fae42e16f82..553d9bc0685 100644
--- a/packages/electron-builder/src/options/winOptions.ts
+++ b/packages/electron-builder/src/options/winOptions.ts
@@ -231,6 +231,12 @@ export interface NsisOptions extends CommonNsisOptions, TargetSpecificOptions {
* @default false
*/
readonly deleteAppDataOnUninstall?: boolean
+
+ /**
+ * Whether to pack the elevate executable
+ * @default false
+ */
+ readonly doNotPackElevateHelper?: boolean
}
/**
diff --git a/packages/electron-builder/src/targets/nsis.ts b/packages/electron-builder/src/targets/nsis.ts
index 41696f5a65b..40dd4e3478d 100644
--- a/packages/electron-builder/src/targets/nsis.ts
+++ b/packages/electron-builder/src/targets/nsis.ts
@@ -13,7 +13,6 @@ import sanitizeFileName from "sanitize-filename"
import { v5 as uuid5 } from "uuid-1345"
import { NsisOptions, PortableOptions } from "../options/winOptions"
import { normalizeExt } from "../platformPackager"
-import { getSignVendorPath } from "../windowsCodeSign"
import { WinPackager } from "../winPackager"
import { archive } from "./archive"
import { bundledLanguages, getLicenseFiles, lcid, toLangWithRegion } from "./license"
@@ -105,10 +104,9 @@ export class NsisTarget extends Target {
/** @private */
async buildAppPackage(appOutDir: string, arch: Arch) {
- await BluebirdPromise.all([
- copyFile(path.join(await nsisPathPromise, "elevate.exe"), path.join(appOutDir, "resources", "elevate.exe"), null, false),
- copyFile(path.join(await getSignVendorPath(), "windows-10", Arch[arch], "signtool.exe"), path.join(appOutDir, "resources", "signtool.exe"), null, false),
- ])
+ if (this.options.doNotPackElevateHelper !== true) {
+ await copyFile(path.join(await nsisPathPromise, "elevate.exe"), path.join(appOutDir, "resources", "elevate.exe"), null, false)
+ }
const packager = this.packager
const format = this.options.useZip ? "zip" : "7z"
diff --git a/test/src/helpers/winHelper.ts b/test/src/helpers/winHelper.ts
index 55ca82a69f5..fb1930b07ec 100644
--- a/test/src/helpers/winHelper.ts
+++ b/test/src/helpers/winHelper.ts
@@ -11,6 +11,7 @@ import { diff, WineManager } from "./wine"
export async function expectUpdateMetadata(context: PackedContext, arch: Arch = Arch.ia32, requireCodeSign: boolean = false): Promise {
const data = safeLoad(await readFile(path.join(context.getResources(Platform.WINDOWS, arch), "app-update.yml"), "utf-8"))
+
if (requireCodeSign && process.env.CSC_KEY_PASSWORD != null) {
expect(data.publisherName).toEqual(["Developer ID Installer: Vladimir Krivosheev (X8C9Z9L4HW)"])
delete data.publisherName
@@ -19,7 +20,7 @@ export async function expectUpdateMetadata(context: PackedContext, arch: Arch =
expect(data).toMatchSnapshot()
}
-export async function doTest(outDir: string, perUser: boolean, productFilename = "TestApp Setup", name = "TestApp", menuCategory: string | null = null) {
+export async function doTest(outDir: string, perUser: boolean, productFilename = "TestApp Setup", name = "TestApp", menuCategory: string | null = null, doNotPackElevateHelper = false) {
if (process.env.DO_WINE !== "true") {
return BluebirdPromise.resolve()
}
@@ -59,6 +60,12 @@ export async function doTest(outDir: string, perUser: boolean, productFilename =
await assertThat(path.join(startMenuDir, `${productFilename}.lnk`)).isFile()
}
+ if (doNotPackElevateHelper) {
+ await assertThat(path.join(instDir, name, "resources", "elevate.exe")).doesNotExist()
+ } else {
+ await assertThat(path.join(instDir, name, "resources", "elevate.exe")).isFile()
+ }
+
let fsAfter = await listFiles()
let fsChanges = diff(fsBefore, fsAfter, driveC)
diff --git a/test/src/windows/oneClickInstallerTest.ts b/test/src/windows/oneClickInstallerTest.ts
index 3e26bcaa655..fc3ac633f6c 100644
--- a/test/src/windows/oneClickInstallerTest.ts
+++ b/test/src/windows/oneClickInstallerTest.ts
@@ -19,12 +19,13 @@ test("one-click", app({
},
nsis: {
deleteAppDataOnUninstall: true,
+ doNotPackElevateHelper: true
},
}
}, {
signed: true,
packed: async (context) => {
- await doTest(context.outDir, true)
+ await doTest(context.outDir, true, "TestApp Setup", "TestApp", null, true)
await expectUpdateMetadata(context, Arch.ia32, true)
}
}))