diff --git a/.changeset/dull-brooms-search.md b/.changeset/dull-brooms-search.md
new file mode 100644
index 00000000000..27a8414155c
--- /dev/null
+++ b/.changeset/dull-brooms-search.md
@@ -0,0 +1,5 @@
+---
+"app-builder-lib": minor
+---
+
+feat(nsis): add NsisOption to specify selectPerMachineByDefault
diff --git a/docs/generated/NsisOptions.md b/docs/generated/NsisOptions.md
index ba0cebd857d..6a6d44d1b90 100644
--- a/docs/generated/NsisOptions.md
+++ b/docs/generated/NsisOptions.md
@@ -12,6 +12,9 @@
If oneClick
is false
and perMachine
is false
(default): install mode installer page.
+selectPerMachineByDefault
= false
Boolean - Whether to set per-machine or per-user installation as default selection on the install mode installer page.
+
+
allowElevation
= true
Boolean - assisted installer only. Allow requesting for elevation. If false, user will have to restart installer with elevated permissions.
diff --git a/packages/app-builder-lib/scheme.json b/packages/app-builder-lib/scheme.json
index fc7cd69be72..de502df940e 100644
--- a/packages/app-builder-lib/scheme.json
+++ b/packages/app-builder-lib/scheme.json
@@ -4183,6 +4183,11 @@
"string"
]
},
+ "selectPerMachineByDefault": {
+ "default": false,
+ "description": "Whether to set per-machine or per-user installation as default selection on the install mode installer page.",
+ "type": "boolean"
+ },
"shortcutName": {
"description": "The name that will be used for all shortcuts. Defaults to the application name.",
"type": [
@@ -4506,6 +4511,11 @@
"string"
]
},
+ "selectPerMachineByDefault": {
+ "default": false,
+ "description": "Whether to set per-machine or per-user installation as default selection on the install mode installer page.",
+ "type": "boolean"
+ },
"shortcutName": {
"description": "The name that will be used for all shortcuts. Defaults to the application name.",
"type": [
diff --git a/packages/app-builder-lib/src/targets/nsis/Defines.ts b/packages/app-builder-lib/src/targets/nsis/Defines.ts
index 5402f35b28e..123649e1e0e 100644
--- a/packages/app-builder-lib/src/targets/nsis/Defines.ts
+++ b/packages/app-builder-lib/src/targets/nsis/Defines.ts
@@ -76,6 +76,7 @@ export type Defines = {
MULTIUSER_INSTALLMODE_ALLOW_ELEVATION?: null
INSTALL_MODE_PER_ALL_USERS?: null
+ INSTALL_MODE_PER_ALL_USERS_DEFAULT?: null
INSTALL_MODE_PER_ALL_USERS_REQUIRED?: null
allowToChangeInstallationDirectory?: null
diff --git a/packages/app-builder-lib/src/targets/nsis/NsisTarget.ts b/packages/app-builder-lib/src/targets/nsis/NsisTarget.ts
index 8b4d33cdd26..c676ecf26c1 100644
--- a/packages/app-builder-lib/src/targets/nsis/NsisTarget.ts
+++ b/packages/app-builder-lib/src/targets/nsis/NsisTarget.ts
@@ -474,6 +474,10 @@ export class NsisTarget extends Target {
defines.INSTALL_MODE_PER_ALL_USERS = null
}
+ if (options.selectPerMachineByDefault === true) {
+ defines.INSTALL_MODE_PER_ALL_USERS_DEFAULT = null
+ }
+
if (!oneClick || options.perMachine === true) {
defines.INSTALL_MODE_PER_ALL_USERS_REQUIRED = null
}
diff --git a/packages/app-builder-lib/src/targets/nsis/nsisOptions.ts b/packages/app-builder-lib/src/targets/nsis/nsisOptions.ts
index e8e22ec0419..170e3c9aba3 100644
--- a/packages/app-builder-lib/src/targets/nsis/nsisOptions.ts
+++ b/packages/app-builder-lib/src/targets/nsis/nsisOptions.ts
@@ -74,6 +74,13 @@ export interface NsisOptions extends CommonNsisOptions, CommonWindowsInstallerCo
*/
readonly perMachine?: boolean
+ /**
+ * Whether to set per-machine or per-user installation as default selection on the install mode installer page.
+ *
+ * @default false
+ */
+ readonly selectPerMachineByDefault?: boolean
+
/**
* *assisted installer only.* Allow requesting for elevation. If false, user will have to restart installer with elevated permissions.
* @default true
diff --git a/packages/app-builder-lib/templates/nsis/assistedInstaller.nsh b/packages/app-builder-lib/templates/nsis/assistedInstaller.nsh
index 79401340c16..b7f47526554 100644
--- a/packages/app-builder-lib/templates/nsis/assistedInstaller.nsh
+++ b/packages/app-builder-lib/templates/nsis/assistedInstaller.nsh
@@ -143,7 +143,11 @@
!ifdef INSTALL_MODE_PER_ALL_USERS
!insertmacro setInstallModePerAllUsers
!else
- !insertmacro setInstallModePerUser
+ !ifdef INSTALL_MODE_PER_ALL_USERS_DEFAULT
+ !insertmacro setInstallModePerAllUsers
+ !else
+ !insertmacro setInstallModePerUser
+ !endif
!endif
${endif}
!endif