enhance!(nsis): use !ifmacrodef for installer hooks (#10177)

This commit is contained in:
Tony 2024-07-03 10:48:22 +08:00 committed by GitHub
parent 55733aba9c
commit 11aa7743e7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 31 additions and 34 deletions

View File

@ -0,0 +1,5 @@
---
"tauri-bundler": "patch:breaking"
---
Changed NSIS installer hooks from `!define` to `!macro`

View File

@ -2347,7 +2347,7 @@
] ]
}, },
"installerHooks": { "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": [ "type": [
"string", "string",
"null" "null"

View File

@ -802,23 +802,19 @@ pub struct NsisConfig {
/// ### Example /// ### Example
/// ///
/// ```nsh /// ```nsh
/// !define NSIS_HOOK_PREINSTALL "NSIS_HOOK_PREINSTALL_" /// !macro NSIS_HOOK_PREINSTALL
/// !macro NSIS_HOOK_PREINSTALL_
/// MessageBox MB_OK "PreInstall" /// MessageBox MB_OK "PreInstall"
/// !macroend /// !macroend
/// ///
/// !define NSIS_HOOK_POSTINSTALL "NSIS_HOOK_POSTINSTALL_" /// !macro NSIS_HOOK_POSTINSTALL
/// !macro NSIS_HOOK_POSTINSTALL_
/// MessageBox MB_OK "PostInstall" /// MessageBox MB_OK "PostInstall"
/// !macroend /// !macroend
/// ///
/// !define NSIS_HOOK_PREUNINSTALL "NSIS_HOOK_PREUNINSTALL_" /// !macro NSIS_HOOK_PREUNINSTALL
/// !macro NSIS_HOOK_PREUNINSTALL_
/// MessageBox MB_OK "PreUnInstall" /// MessageBox MB_OK "PreUnInstall"
/// !macroend /// !macroend
/// ///
/// !define NSIS_HOOK_POSTUNINSTALL "NSIS_HOOK_POSTUNINSTALL_" /// !macro NSIS_HOOK_POSTUNINSTALL
/// !macro NSIS_HOOK_POSTUNINSTALL_
/// MessageBox MB_OK "PostUninstall" /// MessageBox MB_OK "PostUninstall"
/// !macroend /// !macroend
/// ///

View File

@ -3033,7 +3033,7 @@ checksum = "e1fc403891a21bcfb7c37834ba66a547a8f402146eba7265b5a6d88059c9ff2f"
[[package]] [[package]]
name = "tauri" name = "tauri"
version = "2.0.0-beta.22" version = "2.0.0-beta.23"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"bytes", "bytes",
@ -3083,7 +3083,7 @@ dependencies = [
[[package]] [[package]]
name = "tauri-build" name = "tauri-build"
version = "2.0.0-beta.17" version = "2.0.0-beta.18"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"cargo_toml", "cargo_toml",
@ -3105,7 +3105,7 @@ dependencies = [
[[package]] [[package]]
name = "tauri-codegen" name = "tauri-codegen"
version = "2.0.0-beta.17" version = "2.0.0-beta.18"
dependencies = [ dependencies = [
"base64 0.22.1", "base64 0.22.1",
"brotli", "brotli",
@ -3130,7 +3130,7 @@ dependencies = [
[[package]] [[package]]
name = "tauri-macros" name = "tauri-macros"
version = "2.0.0-beta.17" version = "2.0.0-beta.18"
dependencies = [ dependencies = [
"heck 0.5.0", "heck 0.5.0",
"proc-macro2", "proc-macro2",
@ -3142,7 +3142,7 @@ dependencies = [
[[package]] [[package]]
name = "tauri-plugin" name = "tauri-plugin"
version = "2.0.0-beta.17" version = "2.0.0-beta.18"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"glob", "glob",
@ -3168,7 +3168,7 @@ dependencies = [
[[package]] [[package]]
name = "tauri-runtime" name = "tauri-runtime"
version = "2.0.0-beta.18" version = "2.0.0-beta.19"
dependencies = [ dependencies = [
"dpi", "dpi",
"gtk", "gtk",
@ -3185,7 +3185,7 @@ dependencies = [
[[package]] [[package]]
name = "tauri-runtime-wry" name = "tauri-runtime-wry"
version = "2.0.0-beta.18" version = "2.0.0-beta.19"
dependencies = [ dependencies = [
"cocoa", "cocoa",
"gtk", "gtk",
@ -3207,7 +3207,7 @@ dependencies = [
[[package]] [[package]]
name = "tauri-utils" name = "tauri-utils"
version = "2.0.0-beta.17" version = "2.0.0-beta.18"
dependencies = [ dependencies = [
"aes-gcm", "aes-gcm",
"brotli", "brotli",

View File

@ -440,23 +440,19 @@ pub struct NsisSettings {
/// ### Example /// ### Example
/// ///
/// ```nsh /// ```nsh
/// !define NSIS_HOOK_PREINSTALL "NSIS_HOOK_PREINSTALL_" /// !macro NSIS_HOOK_PREINSTALL
/// !macro NSIS_HOOK_PREINSTALL_
/// MessageBox MB_OK "PreInstall" /// MessageBox MB_OK "PreInstall"
/// !macroend /// !macroend
/// ///
/// !define NSIS_HOOK_POSTINSTALL "NSIS_HOOK_POSTINSTALL_" /// !macro NSIS_HOOK_POSTINSTALL
/// !macro NSIS_HOOK_POSTINSTALL_
/// MessageBox MB_OK "PostInstall" /// MessageBox MB_OK "PostInstall"
/// !macroend /// !macroend
/// ///
/// !define NSIS_HOOK_PREUNINSTALL "NSIS_HOOK_PREUNINSTALL_" /// !macro NSIS_HOOK_PREUNINSTALL
/// !macro NSIS_HOOK_PREUNINSTALL_
/// MessageBox MB_OK "PreUnInstall" /// MessageBox MB_OK "PreUnInstall"
/// !macroend /// !macroend
/// ///
/// !define NSIS_HOOK_POSTUNINSTALL "NSIS_HOOK_POSTUNINSTALL_" /// !macro NSIS_HOOK_POSTUNINSTALL
/// !macro NSIS_HOOK_POSTUNINSTALL_
/// MessageBox MB_OK "PostUninstall" /// MessageBox MB_OK "PostUninstall"
/// !macroend /// !macroend
/// ``` /// ```

View File

@ -558,8 +558,8 @@ Section Install
!insertmacro CheckIfAppIsRunning !insertmacro CheckIfAppIsRunning
!ifdef NSIS_HOOK_PREINSTALL !ifmacrodef NSIS_HOOK_PREINSTALL
!insertmacro "${NSIS_HOOK_PREINSTALL}" !insertmacro NSIS_HOOK_PREINSTALL
!endif !endif
; Copy main executable ; Copy main executable
@ -638,8 +638,8 @@ Section Install
Call CreateOrUpdateDesktopShortcut Call CreateOrUpdateDesktopShortcut
${EndIf} ${EndIf}
!ifdef NSIS_HOOK_POSTINSTALL !ifmacrodef NSIS_HOOK_POSTINSTALL
!insertmacro "${NSIS_HOOK_POSTINSTALL}" !insertmacro NSIS_HOOK_POSTINSTALL
!endif !endif
; Auto close this page for passive mode ; Auto close this page for passive mode
@ -685,8 +685,8 @@ Section Uninstall
!insertmacro CheckIfAppIsRunning !insertmacro CheckIfAppIsRunning
!ifdef NSIS_HOOK_PREUNINSTALL !ifmacrodef NSIS_HOOK_PREUNINSTALL
!insertmacro "${NSIS_HOOK_PREUNINSTALL}" !insertmacro NSIS_HOOK_PREUNINSTALL
!endif !endif
; Delete the app directory and its content from disk ; Delete the app directory and its content from disk
@ -776,8 +776,8 @@ Section Uninstall
RmDir /r "$LOCALAPPDATA\${BUNDLEID}" RmDir /r "$LOCALAPPDATA\${BUNDLEID}"
${EndIf} ${EndIf}
!ifdef NSIS_HOOK_POSTUNINSTALL !ifmacrodef NSIS_HOOK_POSTUNINSTALL
!insertmacro "${NSIS_HOOK_POSTUNINSTALL}" !insertmacro NSIS_HOOK_PREUNINSTALL
!endif !endif
; Auto close if passive mode ; Auto close if passive mode

View File

@ -2347,7 +2347,7 @@
] ]
}, },
"installerHooks": { "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": [ "type": [
"string", "string",
"null" "null"