Skip to content

Commit 0a30846

Browse files
authored
fix: Change DEBUG_LOGGING env var for nsis installers as part of customNsisBinary config (#6729)
* Exposing `customNsisBinary` and changing env var for `debugLogging` so that it doesn't conflict with other custom nsis scripts that use `DEBUG_LOGGING` env var. Fixes #6715
1 parent 4eaab19 commit 0a30846

File tree

9 files changed

+38
-50
lines changed

9 files changed

+38
-50
lines changed

.changeset/cold-masks-bathe.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"app-builder-lib": patch
3+
---
4+
5+
fix: Change DEBUG_LOGGING env var for nsis installers as part of `customNsisBinary` config. Fixes #6715

.github/workflows/test.yaml

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ name: Test
22

33
on:
44
push:
5-
pull_request:
65

76
# Allows you to run this workflow manually from the Actions tab
87
workflow_dispatch:

docs/generated/NsisOptions.md

+1
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
<li><code id="NsisOptions-unicode">unicode</code> = <code>true</code> Boolean - Whether to create <a href="http://nsis.sourceforge.net/Docs/Chapter1.html#intro-unicode">Unicode installer</a>.</li>
6060
<li><code id="NsisOptions-guid">guid</code> String | “undefined” - See <a href="../configuration/nsis#guid-vs-application-name">GUID vs Application Name</a>.</li>
6161
<li><code id="NsisOptions-warningsAsErrors">warningsAsErrors</code> = <code>true</code> Boolean - If <code>warningsAsErrors</code> is <code>true</code> (default): NSIS will treat warnings as errors. If <code>warningsAsErrors</code> is <code>false</code>: NSIS will allow warnings.</li>
62+
<li><code id="NsisOptions-customNsisBinary">customNsisBinary</code> module:app-builder-lib/out/targets/nsis/nsisOptions.CustomNsisBinary | “undefined” - Allows you to provide your own <code>makensis</code>, such as one with support for debug logging via LogSet and LogText. (Logging also requires option <code>debugLogging = true</code>)</li>
6263
<li><code id="NsisOptions-runAfterFinish">runAfterFinish</code> = <code>true</code> Boolean - Whether to run the installed application after finish. For assisted installer corresponding checkbox will be removed.</li>
6364
</ul>
6465
<hr>

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"generate-changeset": "pnpm changeset",
2929
"generate-docs": "pnpm compile && pnpm jsdoc && pnpm jsdoc2md2html",
3030
"ci:test": "node ./test/out/helpers/runTests.js",
31-
"ci:version": "pnpm changelog && changeset version && node scripts/update-package-version-export.js && pnpm run generate-docs && pnpm run prettier && git add .",
31+
"ci:version": "pnpm changelog && changeset version && node scripts/update-package-version-export.js && pnpm run schema && pnpm run generate-docs && pnpm run prettier && git add .",
3232
"ci:publish": "pnpm compile && pnpm publish -r && changeset tag",
3333
"schema": "typescript-json-schema packages/app-builder-lib/tsconfig-scheme.json Configuration --out packages/app-builder-lib/scheme.json --noExtraProps --useTypeOfKeyword --strictNullChecks --required && node ./scripts/fix-schema.js",
3434
"jsdoc": "ts2jsdoc packages/builder-util-runtime packages/builder-util packages/app-builder-lib packages/electron-builder packages/electron-publish packages/electron-updater packages/dmg-builder",

packages/app-builder-lib/scheme.json

+13-24
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,13 @@
419419
"string"
420420
]
421421
},
422+
"debugLogging": {
423+
"description": "Whether or not to enable NSIS logging for debugging.\nNote: Requires a debug-enabled NSIS build.\nelectron-builder's included `makensis` does not natively support debug-enabled NSIS installers currently, you must supply your own via `customNsisBinary?: CustomNsisBinary`\nIn your custom nsis scripts, you can leverage this functionality via `LogSet` and `LogText`",
424+
"type": [
425+
"null",
426+
"boolean"
427+
]
428+
},
422429
"url": {
423430
"default": "https://github.com/electron-userland/electron-builder-binaries/releases/download",
424431
"type": [
@@ -3646,14 +3653,8 @@
36463653
{
36473654
"type": "null"
36483655
}
3649-
]
3650-
},
3651-
"debugLogging": {
3652-
"description": "Whether or not to enable NSIS logging for debugging.\nNote: Requires a debug-enabled NSIS build.\nelectron-builder's included `makensis` only supports building debug-enabled NSIS installers on Windows currently\nhttps://github.com/electron-userland/electron-builder/issues/5119#issuecomment-811353612",
3653-
"type": [
3654-
"null",
3655-
"boolean"
3656-
]
3656+
],
3657+
"description": "Allows you to provide your own `makensis`, such as one with support for debug logging via LogSet and LogText. (Logging also requires option `debugLogging = true`)"
36573658
},
36583659
"deleteAppDataOnUninstall": {
36593660
"default": false,
@@ -3970,14 +3971,8 @@
39703971
{
39713972
"type": "null"
39723973
}
3973-
]
3974-
},
3975-
"debugLogging": {
3976-
"description": "Whether or not to enable NSIS logging for debugging.\nNote: Requires a debug-enabled NSIS build.\nelectron-builder's included `makensis` only supports building debug-enabled NSIS installers on Windows currently\nhttps://github.com/electron-userland/electron-builder/issues/5119#issuecomment-811353612",
3977-
"type": [
3978-
"null",
3979-
"boolean"
3980-
]
3974+
],
3975+
"description": "Allows you to provide your own `makensis`, such as one with support for debug logging via LogSet and LogText. (Logging also requires option `debugLogging = true`)"
39813976
},
39823977
"deleteAppDataOnUninstall": {
39833978
"default": false,
@@ -4560,14 +4555,8 @@
45604555
{
45614556
"type": "null"
45624557
}
4563-
]
4564-
},
4565-
"debugLogging": {
4566-
"description": "Whether or not to enable NSIS logging for debugging.\nNote: Requires a debug-enabled NSIS build.\nelectron-builder's included `makensis` only supports building debug-enabled NSIS installers on Windows currently\nhttps://github.com/electron-userland/electron-builder/issues/5119#issuecomment-811353612",
4567-
"type": [
4568-
"null",
4569-
"boolean"
4570-
]
4558+
],
4559+
"description": "Allows you to provide your own `makensis`, such as one with support for debug logging via LogSet and LogText. (Logging also requires option `debugLogging = true`)"
45714560
},
45724561
"guid": {
45734562
"description": "See [GUID vs Application Name](../configuration/nsis#guid-vs-application-name).",

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -191,8 +191,8 @@ export class NsisTarget extends Target {
191191

192192
APP_PACKAGE_NAME: appInfo.name,
193193
}
194-
if (options.debugLogging) {
195-
defines.ENABLE_LOGGING = null
194+
if (options.customNsisBinary?.debugLogging) {
195+
defines.ENABLE_LOGGING_ELECTRON_BUILDER = null
196196
}
197197
if (uninstallAppKey !== guid) {
198198
defines.UNINSTALL_REGISTRY_KEY_2 = `Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\${guid}`
@@ -370,7 +370,7 @@ export class NsisTarget extends Target {
370370
if (isMacOsCatalina()) {
371371
try {
372372
await UninstallerReader.exec(installerPath, uninstallerPath)
373-
} catch (error) {
373+
} catch (error: any) {
374374
log.warn(`packager.vm is used: ${error.message}`)
375375

376376
const vm = await packager.vm.value

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

+9-16
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,27 @@ import { CommonWindowsInstallerConfiguration } from "../.."
33

44
interface CustomNsisBinary {
55
/**
6-
* @private
76
* @default https://github.com/electron-userland/electron-builder-binaries/releases/download
87
*/
9-
108
readonly url: string | null
119

1210
/**
13-
* @private
1411
* @default VKMiizYdmNdJOWpRGz4trl4lD++BvYP2irAXpMilheUP0pc93iKlWAoP843Vlraj8YG19CVn0j+dCo/hURz9+Q==
1512
*/
16-
1713
readonly checksum?: string | null
1814

1915
/**
20-
* @private
2116
* @default 3.0.4.1
2217
*/
23-
2418
readonly version?: string | null
19+
20+
/**
21+
* Whether or not to enable NSIS logging for debugging.
22+
* Note: Requires a debug-enabled NSIS build.
23+
* electron-builder's included `makensis` does not natively support debug-enabled NSIS installers currently, you must supply your own via `customNsisBinary?: CustomNsisBinary`
24+
* In your custom nsis scripts, you can leverage this functionality via `LogSet` and `LogText`
25+
*/
26+
readonly debugLogging?: boolean | null
2527
}
2628
export interface CommonNsisOptions {
2729
/**
@@ -48,18 +50,9 @@ export interface CommonNsisOptions {
4850
readonly useZip?: boolean
4951

5052
/**
51-
* @private
53+
* Allows you to provide your own `makensis`, such as one with support for debug logging via LogSet and LogText. (Logging also requires option `debugLogging = true`)
5254
*/
5355
readonly customNsisBinary?: CustomNsisBinary | null
54-
55-
/**
56-
* Whether or not to enable NSIS logging for debugging.
57-
* Note: Requires a debug-enabled NSIS build.
58-
* electron-builder's included `makensis` only supports building debug-enabled NSIS installers on Windows currently
59-
* https://github.com/electron-userland/electron-builder/issues/5119#issuecomment-811353612
60-
* @private
61-
*/
62-
readonly debugLogging?: boolean | null
6356
}
6457

6558
export interface NsisOptions extends CommonNsisOptions, CommonWindowsInstallerConfiguration, TargetSpecificOptions {

packages/app-builder-lib/templates/nsis/common.nsh

+5-4
Original file line numberDiff line numberDiff line change
@@ -102,14 +102,15 @@ Name "${PRODUCT_NAME}"
102102

103103
!define LogSet "!insertmacro LogSetMacro"
104104
!macro LogSetMacro SETTING
105-
!ifdef ENABLE_LOGGING
105+
!ifdef ENABLE_LOGGING_ELECTRON_BUILDER
106+
SetOutPath $INSTDIR
106107
LogSet ${SETTING}
107108
!endif
108109
!macroend
109110

110-
!define LogText "!insertmacro LogTextMacro"
111-
!macro LogTextMacro INPUT_TEXT
112-
!ifdef ENABLE_LOGGING
111+
!define LogText "!insertmacro LogTextMacroEB"
112+
!macro LogTextMacroEB INPUT_TEXT
113+
!ifdef ENABLE_LOGGING_ELECTRON_BUILDER
113114
LogText ${INPUT_TEXT}
114115
!endif
115116
!macroend

test/src/windows/assistedInstallerTest.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,8 @@ test.skip.ifNotCiMac(
127127
url: "https://github.com/electron-userland/electron-builder-binaries/releases/download/nsis-3.0.4.2/nsis-3.0.4.2.7z",
128128
version: "3.0.4.2",
129129
checksum: "o+YZsXHp8LNihhuk7JsCDhdIgx0MKKK+1b3sGD+4zX5djZULe4/4QMcAsfQ+0r+a8FnwBt7BVBHkIkJHjKQ0sg==",
130+
debugLogging: true,
130131
},
131-
debugLogging: true,
132132
},
133133
},
134134
})

0 commit comments

Comments
 (0)