Skip to content

Commit 11aa774

Browse files
enhance!(nsis): use !ifmacrodef for installer hooks (#10177)
1 parent 55733ab commit 11aa774

7 files changed

Lines changed: 31 additions & 34 deletions

File tree

.changes/nsis-ifmacrodef.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"tauri-bundler": "patch:breaking"
3+
---
4+
5+
Changed NSIS installer hooks from `!define` to `!macro`

core/tauri-config-schema/schema.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2347,7 +2347,7 @@
23472347
]
23482348
},
23492349
"installerHooks": {
2350-
"description": "A path to a `.nsh` file that contains special NSIS macros to be hooked into the\n main installer.nsi script.\n\n Supported hooks are:\n - `NSIS_HOOK_PREINSTALL`: This hook runs before copying files, setting registry key values and creating shortcuts.\n - `NSIS_HOOK_POSTINSTALL`: This hook runs after the installer has finished copying all files, setting the registry keys and created shortcuts.\n - `NSIS_HOOK_PREUNINSTALL`: This hook runs before removing any files, registry keys and shortcuts.\n - `NSIS_HOOK_POSTUNINSTALL`: This hook runs after files, registry keys and shortcuts have been removed.\n\n\n ### Example\n\n ```nsh\n !define NSIS_HOOK_PREINSTALL \"NSIS_HOOK_PREINSTALL_\"\n !macro NSIS_HOOK_PREINSTALL_\n MessageBox MB_OK \"PreInstall\"\n !macroend\n\n !define NSIS_HOOK_POSTINSTALL \"NSIS_HOOK_POSTINSTALL_\"\n !macro NSIS_HOOK_POSTINSTALL_\n MessageBox MB_OK \"PostInstall\"\n !macroend\n\n !define NSIS_HOOK_PREUNINSTALL \"NSIS_HOOK_PREUNINSTALL_\"\n !macro NSIS_HOOK_PREUNINSTALL_\n MessageBox MB_OK \"PreUnInstall\"\n !macroend\n\n !define NSIS_HOOK_POSTUNINSTALL \"NSIS_HOOK_POSTUNINSTALL_\"\n !macro NSIS_HOOK_POSTUNINSTALL_\n MessageBox MB_OK \"PostUninstall\"\n !macroend\n\n ```",
2350+
"description": "A path to a `.nsh` file that contains special NSIS macros to be hooked into the\n main installer.nsi script.\n\n Supported hooks are:\n - `NSIS_HOOK_PREINSTALL`: This hook runs before copying files, setting registry key values and creating shortcuts.\n - `NSIS_HOOK_POSTINSTALL`: This hook runs after the installer has finished copying all files, setting the registry keys and created shortcuts.\n - `NSIS_HOOK_PREUNINSTALL`: This hook runs before removing any files, registry keys and shortcuts.\n - `NSIS_HOOK_POSTUNINSTALL`: This hook runs after files, registry keys and shortcuts have been removed.\n\n\n ### Example\n\n ```nsh\n !macro NSIS_HOOK_PREINSTALL\n MessageBox MB_OK \"PreInstall\"\n !macroend\n\n !macro NSIS_HOOK_POSTINSTALL\n MessageBox MB_OK \"PostInstall\"\n !macroend\n\n !macro NSIS_HOOK_PREUNINSTALL\n MessageBox MB_OK \"PreUnInstall\"\n !macroend\n\n !macro NSIS_HOOK_POSTUNINSTALL\n MessageBox MB_OK \"PostUninstall\"\n !macroend\n\n ```",
23512351
"type": [
23522352
"string",
23532353
"null"

core/tauri-utils/src/config.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -802,23 +802,19 @@ pub struct NsisConfig {
802802
/// ### Example
803803
///
804804
/// ```nsh
805-
/// !define NSIS_HOOK_PREINSTALL "NSIS_HOOK_PREINSTALL_"
806-
/// !macro NSIS_HOOK_PREINSTALL_
805+
/// !macro NSIS_HOOK_PREINSTALL
807806
/// MessageBox MB_OK "PreInstall"
808807
/// !macroend
809808
///
810-
/// !define NSIS_HOOK_POSTINSTALL "NSIS_HOOK_POSTINSTALL_"
811-
/// !macro NSIS_HOOK_POSTINSTALL_
809+
/// !macro NSIS_HOOK_POSTINSTALL
812810
/// MessageBox MB_OK "PostInstall"
813811
/// !macroend
814812
///
815-
/// !define NSIS_HOOK_PREUNINSTALL "NSIS_HOOK_PREUNINSTALL_"
816-
/// !macro NSIS_HOOK_PREUNINSTALL_
813+
/// !macro NSIS_HOOK_PREUNINSTALL
817814
/// MessageBox MB_OK "PreUnInstall"
818815
/// !macroend
819816
///
820-
/// !define NSIS_HOOK_POSTUNINSTALL "NSIS_HOOK_POSTUNINSTALL_"
821-
/// !macro NSIS_HOOK_POSTUNINSTALL_
817+
/// !macro NSIS_HOOK_POSTUNINSTALL
822818
/// MessageBox MB_OK "PostUninstall"
823819
/// !macroend
824820
///

examples/api/src-tauri/Cargo.lock

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tooling/bundler/src/bundle/settings.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -440,23 +440,19 @@ pub struct NsisSettings {
440440
/// ### Example
441441
///
442442
/// ```nsh
443-
/// !define NSIS_HOOK_PREINSTALL "NSIS_HOOK_PREINSTALL_"
444-
/// !macro NSIS_HOOK_PREINSTALL_
443+
/// !macro NSIS_HOOK_PREINSTALL
445444
/// MessageBox MB_OK "PreInstall"
446445
/// !macroend
447446
///
448-
/// !define NSIS_HOOK_POSTINSTALL "NSIS_HOOK_POSTINSTALL_"
449-
/// !macro NSIS_HOOK_POSTINSTALL_
447+
/// !macro NSIS_HOOK_POSTINSTALL
450448
/// MessageBox MB_OK "PostInstall"
451449
/// !macroend
452450
///
453-
/// !define NSIS_HOOK_PREUNINSTALL "NSIS_HOOK_PREUNINSTALL_"
454-
/// !macro NSIS_HOOK_PREUNINSTALL_
451+
/// !macro NSIS_HOOK_PREUNINSTALL
455452
/// MessageBox MB_OK "PreUnInstall"
456453
/// !macroend
457454
///
458-
/// !define NSIS_HOOK_POSTUNINSTALL "NSIS_HOOK_POSTUNINSTALL_"
459-
/// !macro NSIS_HOOK_POSTUNINSTALL_
455+
/// !macro NSIS_HOOK_POSTUNINSTALL
460456
/// MessageBox MB_OK "PostUninstall"
461457
/// !macroend
462458
/// ```

tooling/bundler/src/bundle/windows/templates/installer.nsi

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -558,8 +558,8 @@ Section Install
558558

559559
!insertmacro CheckIfAppIsRunning
560560

561-
!ifdef NSIS_HOOK_PREINSTALL
562-
!insertmacro "${NSIS_HOOK_PREINSTALL}"
561+
!ifmacrodef NSIS_HOOK_PREINSTALL
562+
!insertmacro NSIS_HOOK_PREINSTALL
563563
!endif
564564

565565
; Copy main executable
@@ -638,8 +638,8 @@ Section Install
638638
Call CreateOrUpdateDesktopShortcut
639639
${EndIf}
640640

641-
!ifdef NSIS_HOOK_POSTINSTALL
642-
!insertmacro "${NSIS_HOOK_POSTINSTALL}"
641+
!ifmacrodef NSIS_HOOK_POSTINSTALL
642+
!insertmacro NSIS_HOOK_POSTINSTALL
643643
!endif
644644

645645
; Auto close this page for passive mode
@@ -685,8 +685,8 @@ Section Uninstall
685685

686686
!insertmacro CheckIfAppIsRunning
687687

688-
!ifdef NSIS_HOOK_PREUNINSTALL
689-
!insertmacro "${NSIS_HOOK_PREUNINSTALL}"
688+
!ifmacrodef NSIS_HOOK_PREUNINSTALL
689+
!insertmacro NSIS_HOOK_PREUNINSTALL
690690
!endif
691691

692692
; Delete the app directory and its content from disk
@@ -776,8 +776,8 @@ Section Uninstall
776776
RmDir /r "$LOCALAPPDATA\${BUNDLEID}"
777777
${EndIf}
778778

779-
!ifdef NSIS_HOOK_POSTUNINSTALL
780-
!insertmacro "${NSIS_HOOK_POSTUNINSTALL}"
779+
!ifmacrodef NSIS_HOOK_POSTUNINSTALL
780+
!insertmacro NSIS_HOOK_PREUNINSTALL
781781
!endif
782782

783783
; Auto close if passive mode

tooling/cli/schema.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2347,7 +2347,7 @@
23472347
]
23482348
},
23492349
"installerHooks": {
2350-
"description": "A path to a `.nsh` file that contains special NSIS macros to be hooked into the\n main installer.nsi script.\n\n Supported hooks are:\n - `NSIS_HOOK_PREINSTALL`: This hook runs before copying files, setting registry key values and creating shortcuts.\n - `NSIS_HOOK_POSTINSTALL`: This hook runs after the installer has finished copying all files, setting the registry keys and created shortcuts.\n - `NSIS_HOOK_PREUNINSTALL`: This hook runs before removing any files, registry keys and shortcuts.\n - `NSIS_HOOK_POSTUNINSTALL`: This hook runs after files, registry keys and shortcuts have been removed.\n\n\n ### Example\n\n ```nsh\n !define NSIS_HOOK_PREINSTALL \"NSIS_HOOK_PREINSTALL_\"\n !macro NSIS_HOOK_PREINSTALL_\n MessageBox MB_OK \"PreInstall\"\n !macroend\n\n !define NSIS_HOOK_POSTINSTALL \"NSIS_HOOK_POSTINSTALL_\"\n !macro NSIS_HOOK_POSTINSTALL_\n MessageBox MB_OK \"PostInstall\"\n !macroend\n\n !define NSIS_HOOK_PREUNINSTALL \"NSIS_HOOK_PREUNINSTALL_\"\n !macro NSIS_HOOK_PREUNINSTALL_\n MessageBox MB_OK \"PreUnInstall\"\n !macroend\n\n !define NSIS_HOOK_POSTUNINSTALL \"NSIS_HOOK_POSTUNINSTALL_\"\n !macro NSIS_HOOK_POSTUNINSTALL_\n MessageBox MB_OK \"PostUninstall\"\n !macroend\n\n ```",
2350+
"description": "A path to a `.nsh` file that contains special NSIS macros to be hooked into the\n main installer.nsi script.\n\n Supported hooks are:\n - `NSIS_HOOK_PREINSTALL`: This hook runs before copying files, setting registry key values and creating shortcuts.\n - `NSIS_HOOK_POSTINSTALL`: This hook runs after the installer has finished copying all files, setting the registry keys and created shortcuts.\n - `NSIS_HOOK_PREUNINSTALL`: This hook runs before removing any files, registry keys and shortcuts.\n - `NSIS_HOOK_POSTUNINSTALL`: This hook runs after files, registry keys and shortcuts have been removed.\n\n\n ### Example\n\n ```nsh\n !macro NSIS_HOOK_PREINSTALL\n MessageBox MB_OK \"PreInstall\"\n !macroend\n\n !macro NSIS_HOOK_POSTINSTALL\n MessageBox MB_OK \"PostInstall\"\n !macroend\n\n !macro NSIS_HOOK_PREUNINSTALL\n MessageBox MB_OK \"PreUnInstall\"\n !macroend\n\n !macro NSIS_HOOK_POSTUNINSTALL\n MessageBox MB_OK \"PostUninstall\"\n !macroend\n\n ```",
23512351
"type": [
23522352
"string",
23532353
"null"

0 commit comments

Comments
 (0)