Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Do not pack "elevate.exe" when not needed #1621

Closed
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Define and use doNotPackElevateHelper nsis option
Revert the changes for the installer.
Don't pack the signtool.exe at all.
MariaDima committed Jun 8, 2017
commit d5d10cb6a260d2937f72e458393778e124f2d805
2 changes: 1 addition & 1 deletion docs/Options.md
Original file line number Diff line number Diff line change
@@ -438,7 +438,7 @@ See [NSIS target notes](https://github.com/electron-userland/electron-builder/wi
| artifactName| <code>string</code> \| <code>null</code> | <a name="NsisOptions-artifactName"></a>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 = <code>true</code>| <code>boolean</code> | <a name="NsisOptions-unicode"></a>Whether to create [Unicode installer](http://nsis.sourceforge.net/Docs/Chapter1.html#intro-unicode). |
| deleteAppDataOnUninstall| <code>boolean</code> | <a name="NsisOptions-deleteAppDataOnUninstall"></a>*one-click installer only.* Whether to delete app data on uninstall. |
| deleteSupportingFilesAfterInstall = <code>false</code>| <code>boolean</code> | <a name="NsisOptions-deleteSupportingFilesAfterInstall"></a> Whether to delete the files that are packed to support the installation. |
| doNotPackElevateHelper = <code>false</code>| <code>boolean</code> | <a name="NsisOptions-doNotPackElevateHelper"></a> Whether to pack the elevate executable. |

<a name="NsisWebOptions"></a>

4 changes: 2 additions & 2 deletions packages/electron-builder/src/options/winOptions.ts
Original file line number Diff line number Diff line change
@@ -226,10 +226,10 @@ export interface NsisOptions extends CommonNsisOptions, TargetSpecificOptions {
readonly deleteAppDataOnUninstall?: boolean

/**
* Whether to delete the files that are packed to support the installation.
* Whether to pack the elevate executable
* @default false
*/
readonly deleteSupportingFilesAfterInstall?: boolean
readonly doNotPackElevateHelper?: boolean
}

/**
12 changes: 3 additions & 9 deletions packages/electron-builder/src/targets/nsis.ts
Original file line number Diff line number Diff line change
@@ -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"
@@ -106,10 +105,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"
@@ -365,10 +363,6 @@ export class NsisTarget extends Target {
defines.UNINSTALLER_ICON = uninstallerIcon
defines.MUI_UNICON = uninstallerIcon
}

if (options.deleteSupportingFilesAfterInstall) {
defines.DELETE_SUPPORTING_FILES_AFTER_INSTALL = null
}
}

private configureDefinesForAllTypeOfInstaller(defines: any) {
5 changes: 0 additions & 5 deletions packages/electron-builder/templates/nsis/installSection.nsh
Original file line number Diff line number Diff line change
@@ -196,11 +196,6 @@ WinShell::SetLnkAUMI "$desktopLink" "${APP_ID}"
!insertmacro customInstall
!endif

!ifdef DELETE_SUPPORTING_FILES_AFTER_INSTALL
Delete $INSTDIR\resources\elevate.exe
Delete $INSTDIR\resources\signtool.exe
!endif

!ifdef ONE_CLICK
!ifdef RUN_AFTER_FINISH
${IfNot} ${Silent}
6 changes: 0 additions & 6 deletions test/out/windows/__snapshots__/oneClickInstallerTest.js.snap
Original file line number Diff line number Diff line change
@@ -24,12 +24,6 @@ Object {
}
`;

exports[`delete supporting files after install 1`] = `
Object {
"win": Array [],
}
`;

exports[`file associations only perMachine 1`] = `"Please set perMachine to true — file associations works on Windows only if installed for all users"`;

exports[`installerHeaderIcon 1`] = `
8 changes: 7 additions & 1 deletion test/src/helpers/winHelper.ts
Original file line number Diff line number Diff line change
@@ -20,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()
}
@@ -60,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)
26 changes: 4 additions & 22 deletions test/src/windows/oneClickInstallerTest.ts
Original file line number Diff line number Diff line change
@@ -18,19 +18,15 @@ test("one-click", app({
package: "TestApp",
},
nsis: {
deleteAppDataOnUninstall: true
deleteAppDataOnUninstall: true,
doNotPackElevateHelper: true
},
},
effectiveOptionComputed: async (it) => {
const defines = it[0]
expect(defines.DELETE_SUPPORTING_FILES_AFTER_INSTALL).not.toBeDefined()
return false
}
}, {
signed: true,
packed: async (context) => {
await doTest(context.outDir, true)
await expectUpdateMetadata(context, Arch.ia32, true, false)
await doTest(context.outDir, true, "TestApp Setup", "TestApp", null, true)
await expectUpdateMetadata(context, Arch.ia32, true)
}
}))

@@ -211,18 +207,4 @@ test.ifAll.ifNotCiMac("web installer (default github)", app({
delete data.sha512
expect(data).toMatchSnapshot()
},
}))

test("delete supporting files after install", app({
targets: nsisTarget,
config: {
nsis: {
deleteSupportingFilesAfterInstall: true
}
},
effectiveOptionComputed: async (it) => {
const defines = it[0]
expect(defines.DELETE_SUPPORTING_FILES_AFTER_INSTALL).toBeDefined()
return true
}
}))