Skip to content

Commit

Permalink
fix(nsis): Decide to use elevate.exe for installer when update using …
Browse files Browse the repository at this point in the history
…nsis packElevateHelper option in electron-builder config (#6787)

If window service needs to run installer for update, the installer must have admin previlege. Electron-updater detects whether elevating or not using isAdminRightsRequired in update-info.json. And this isAdminRightsRequired true option should be added to latest.yml using nsis's packElevateHelper option
  • Loading branch information
HwangTaehyun authored Apr 19, 2022
1 parent 8254d7d commit eb456a8
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/poor-windows-heal.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"app-builder-lib": patch
---

If window service needs to run installer for update, the installer must have admin previlege. Electron-updater detects whether elevating or not using isAdminRightsRequired in update-info.json. And this isAdminRightsRequired true option should be added to latest.yml using nsis's packElevateHelper option
3 changes: 2 additions & 1 deletion packages/app-builder-lib/src/targets/nsis/NsisTarget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ export class NsisTarget extends Target {
.join(", "),
}
const isPerMachine = options.perMachine === true

if (!this.isPortable) {
logFields.oneClick = oneClick
logFields.perMachine = isPerMachine
Expand Down Expand Up @@ -319,7 +320,7 @@ export class NsisTarget extends Target {
updateInfo = await createBlockmap(installerPath, this, packager, safeArtifactName)
}

if (updateInfo != null && isPerMachine && oneClick) {
if (updateInfo != null && isPerMachine && (oneClick || options.packElevateHelper)) {
updateInfo.isAdminRightsRequired = true
}

Expand Down
26 changes: 26 additions & 0 deletions test/snapshots/windows/assistedInstallerTest.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -128,3 +128,29 @@ Object {
],
}
`;

exports[`assisted, only perMachine and elevated 1`] = `
Object {
"win": Array [
Object {
"arch": "x64",
"file": "Test App ßW Setup 1.1.0.exe",
"safeArtifactName": "TestApp-Setup-1.1.0.exe",
"updateInfo": Object {
"isAdminRightsRequired": true,
"sha512": "@sha512",
"size": "@size",
},
},
Object {
"file": "Test App ßW Setup 1.1.0.exe.blockmap",
"safeArtifactName": "TestApp-Setup-1.1.0.exe.blockmap",
"updateInfo": Object {
"isAdminRightsRequired": true,
"sha512": "@sha512",
"size": "@size",
},
},
],
}
`;
14 changes: 14 additions & 0 deletions test/src/windows/assistedInstallerTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,20 @@ test.ifNotCiMac(
})
)

test.ifNotCiMac(
"assisted, only perMachine and elevated",
app({
targets: nsisTarget,
config: {
nsis: {
oneClick: false,
perMachine: true,
packElevateHelper: true
},
},
})
)

// test release notes also
test.ifAll.ifNotCiMac(
"allowToChangeInstallationDirectory",
Expand Down

0 comments on commit eb456a8

Please sign in to comment.