Skip to content

Commit eb456a8

Browse files
authored
fix(nsis): Decide to use elevate.exe for installer when update using 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
1 parent 8254d7d commit eb456a8

File tree

4 files changed

+47
-1
lines changed

4 files changed

+47
-1
lines changed

.changeset/poor-windows-heal.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"app-builder-lib": patch
3+
---
4+
5+
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

packages/app-builder-lib/src/targets/nsis/NsisTarget.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ export class NsisTarget extends Target {
159159
.join(", "),
160160
}
161161
const isPerMachine = options.perMachine === true
162+
162163
if (!this.isPortable) {
163164
logFields.oneClick = oneClick
164165
logFields.perMachine = isPerMachine
@@ -319,7 +320,7 @@ export class NsisTarget extends Target {
319320
updateInfo = await createBlockmap(installerPath, this, packager, safeArtifactName)
320321
}
321322

322-
if (updateInfo != null && isPerMachine && oneClick) {
323+
if (updateInfo != null && isPerMachine && (oneClick || options.packElevateHelper)) {
323324
updateInfo.isAdminRightsRequired = true
324325
}
325326

test/snapshots/windows/assistedInstallerTest.js.snap

+26
Original file line numberDiff line numberDiff line change
@@ -128,3 +128,29 @@ Object {
128128
],
129129
}
130130
`;
131+
132+
exports[`assisted, only perMachine and elevated 1`] = `
133+
Object {
134+
"win": Array [
135+
Object {
136+
"arch": "x64",
137+
"file": "Test App ßW Setup 1.1.0.exe",
138+
"safeArtifactName": "TestApp-Setup-1.1.0.exe",
139+
"updateInfo": Object {
140+
"isAdminRightsRequired": true,
141+
"sha512": "@sha512",
142+
"size": "@size",
143+
},
144+
},
145+
Object {
146+
"file": "Test App ßW Setup 1.1.0.exe.blockmap",
147+
"safeArtifactName": "TestApp-Setup-1.1.0.exe.blockmap",
148+
"updateInfo": Object {
149+
"isAdminRightsRequired": true,
150+
"sha512": "@sha512",
151+
"size": "@size",
152+
},
153+
},
154+
],
155+
}
156+
`;

test/src/windows/assistedInstallerTest.ts

+14
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,20 @@ test.ifNotCiMac(
147147
})
148148
)
149149

150+
test.ifNotCiMac(
151+
"assisted, only perMachine and elevated",
152+
app({
153+
targets: nsisTarget,
154+
config: {
155+
nsis: {
156+
oneClick: false,
157+
perMachine: true,
158+
packElevateHelper: true
159+
},
160+
},
161+
})
162+
)
163+
150164
// test release notes also
151165
test.ifAll.ifNotCiMac(
152166
"allowToChangeInstallationDirectory",

0 commit comments

Comments
 (0)