Skip to content

Commit

Permalink
enhance!(nsis): use !ifmacrodef for installer hooks (#10177)
Browse files Browse the repository at this point in the history
  • Loading branch information
Legend-Master authored Jul 3, 2024
1 parent 55733ab commit 11aa774
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 34 deletions.
5 changes: 5 additions & 0 deletions .changes/nsis-ifmacrodef.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"tauri-bundler": "patch:breaking"
---

Changed NSIS installer hooks from `!define` to `!macro`
2 changes: 1 addition & 1 deletion core/tauri-config-schema/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -2347,7 +2347,7 @@
]
},
"installerHooks": {
"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 ```",
"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 ```",
"type": [
"string",
"null"
Expand Down
12 changes: 4 additions & 8 deletions core/tauri-utils/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -802,23 +802,19 @@ pub struct NsisConfig {
/// ### Example
///
/// ```nsh
/// !define NSIS_HOOK_PREINSTALL "NSIS_HOOK_PREINSTALL_"
/// !macro NSIS_HOOK_PREINSTALL_
/// !macro NSIS_HOOK_PREINSTALL
/// MessageBox MB_OK "PreInstall"
/// !macroend
///
/// !define NSIS_HOOK_POSTINSTALL "NSIS_HOOK_POSTINSTALL_"
/// !macro NSIS_HOOK_POSTINSTALL_
/// !macro NSIS_HOOK_POSTINSTALL
/// MessageBox MB_OK "PostInstall"
/// !macroend
///
/// !define NSIS_HOOK_PREUNINSTALL "NSIS_HOOK_PREUNINSTALL_"
/// !macro NSIS_HOOK_PREUNINSTALL_
/// !macro NSIS_HOOK_PREUNINSTALL
/// MessageBox MB_OK "PreUnInstall"
/// !macroend
///
/// !define NSIS_HOOK_POSTUNINSTALL "NSIS_HOOK_POSTUNINSTALL_"
/// !macro NSIS_HOOK_POSTUNINSTALL_
/// !macro NSIS_HOOK_POSTUNINSTALL
/// MessageBox MB_OK "PostUninstall"
/// !macroend
///
Expand Down
16 changes: 8 additions & 8 deletions examples/api/src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 4 additions & 8 deletions tooling/bundler/src/bundle/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -440,23 +440,19 @@ pub struct NsisSettings {
/// ### Example
///
/// ```nsh
/// !define NSIS_HOOK_PREINSTALL "NSIS_HOOK_PREINSTALL_"
/// !macro NSIS_HOOK_PREINSTALL_
/// !macro NSIS_HOOK_PREINSTALL
/// MessageBox MB_OK "PreInstall"
/// !macroend
///
/// !define NSIS_HOOK_POSTINSTALL "NSIS_HOOK_POSTINSTALL_"
/// !macro NSIS_HOOK_POSTINSTALL_
/// !macro NSIS_HOOK_POSTINSTALL
/// MessageBox MB_OK "PostInstall"
/// !macroend
///
/// !define NSIS_HOOK_PREUNINSTALL "NSIS_HOOK_PREUNINSTALL_"
/// !macro NSIS_HOOK_PREUNINSTALL_
/// !macro NSIS_HOOK_PREUNINSTALL
/// MessageBox MB_OK "PreUnInstall"
/// !macroend
///
/// !define NSIS_HOOK_POSTUNINSTALL "NSIS_HOOK_POSTUNINSTALL_"
/// !macro NSIS_HOOK_POSTUNINSTALL_
/// !macro NSIS_HOOK_POSTUNINSTALL
/// MessageBox MB_OK "PostUninstall"
/// !macroend
/// ```
Expand Down
16 changes: 8 additions & 8 deletions tooling/bundler/src/bundle/windows/templates/installer.nsi
Original file line number Diff line number Diff line change
Expand Up @@ -558,8 +558,8 @@ Section Install

!insertmacro CheckIfAppIsRunning

!ifdef NSIS_HOOK_PREINSTALL
!insertmacro "${NSIS_HOOK_PREINSTALL}"
!ifmacrodef NSIS_HOOK_PREINSTALL
!insertmacro NSIS_HOOK_PREINSTALL
!endif

; Copy main executable
Expand Down Expand Up @@ -638,8 +638,8 @@ Section Install
Call CreateOrUpdateDesktopShortcut
${EndIf}

!ifdef NSIS_HOOK_POSTINSTALL
!insertmacro "${NSIS_HOOK_POSTINSTALL}"
!ifmacrodef NSIS_HOOK_POSTINSTALL
!insertmacro NSIS_HOOK_POSTINSTALL
!endif

; Auto close this page for passive mode
Expand Down Expand Up @@ -685,8 +685,8 @@ Section Uninstall

!insertmacro CheckIfAppIsRunning

!ifdef NSIS_HOOK_PREUNINSTALL
!insertmacro "${NSIS_HOOK_PREUNINSTALL}"
!ifmacrodef NSIS_HOOK_PREUNINSTALL
!insertmacro NSIS_HOOK_PREUNINSTALL
!endif

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

!ifdef NSIS_HOOK_POSTUNINSTALL
!insertmacro "${NSIS_HOOK_POSTUNINSTALL}"
!ifmacrodef NSIS_HOOK_POSTUNINSTALL
!insertmacro NSIS_HOOK_PREUNINSTALL
!endif

; Auto close if passive mode
Expand Down
2 changes: 1 addition & 1 deletion tooling/cli/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -2347,7 +2347,7 @@
]
},
"installerHooks": {
"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 ```",
"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 ```",
"type": [
"string",
"null"
Expand Down

0 comments on commit 11aa774

Please sign in to comment.