electron-userland / electron-builder

A complete solution to package and build a ready for distribution Electron app with “auto update” support out of the box
https://www.electron.build
MIT License
13.62k stars 1.74k forks source link

customInstall wrong ${isUpdated} value #8365

Open yoniabitbolkryon opened 2 months ago

yoniabitbolkryon commented 2 months ago

I have a custom installer.nsh script I'm overriding macros customWelcomePage, customInstall, customRemoveFiles, customUnInstall, customUnInit. when I manually upgrade my app, the ${isUpdated} is false in customInstall.. although in other macros it's true. what am I doing wrong?

installer.nsh :

!include x64.nsh
!include LogicLib.nsh

!macro customWelcomePage
    # Welcome Page is not added by default for installer.
    !insertMacro MUI_PAGE_WELCOME
!macroend

!macro customInstall
    ${If} ${isUpdated}
        MessageBox MB_ICONEXCLAMATION|MB_OK "I'm inside customInstall -> isUpdated"
    ${Else}
        MessageBox MB_ICONEXCLAMATION|MB_OK "I'm inside customInstall -> not isUpdated"
    ${EndIf}
!macroend

!macro customRemoveFiles
    ${If} ${isUpdated}
        MessageBox MB_ICONEXCLAMATION|MB_OK "I'm inside customRemoveFiles -> isUpdated"
    ${Else}
        MessageBox MB_ICONEXCLAMATION|MB_OK "I'm inside customRemoveFiles -> not isUpdated"
    ${EndIf}
!macroend

!macro customUnInstall
    ${IfNot} ${isUpdated}
        MessageBox MB_ICONEXCLAMATION|MB_OK "I'm inside customUnInstall -> not isUpdated"
    ${Else}
        MessageBox MB_ICONEXCLAMATION|MB_OK "I'm inside customUnInstall -> isUpdated"
    ${EndIf}
!macroend

!macro customUnInit
    ${IfNot} ${isUpdated}
        MessageBox MB_ICONEXCLAMATION|MB_OK "I'm inside customUnInit -> not isUpdated"
    ${Else}
        MessageBox MB_ICONEXCLAMATION|MB_OK "I'm inside customUnInit -> isUpdated"
    ${EndIf}
!macroend

electron-builder.json:

"nsis": {
    "include": "build/installer.nsh",
    "installerIcon": "build/icon.ico",
    "uninstallerIcon": "build/icon.ico",
    "installerHeaderIcon": "build/icon.ico",
    "deleteAppDataOnUninstall": true,
    "shortcutName": "App",
    "uninstallDisplayName": "App",
    "oneClick": false,
    "perMachine": true,
    "allowToChangeInstallationDirectory": true
  },
  "win": {
    "target": "nsis",
    "artifactName": "App.${ext}",
    "icon": "build/icon.ico",
    "requestedExecutionLevel": "requireAdministrator"
  }
mmaietta commented 2 months ago

I'm not too sure where isUpdated is being set, it's not being actually set to a value in any of the .nsh scripts. I'm wondering if it's a default value supplied by nsis scripts?

Here's an alternative route that could be used though! ${if} $1 != 'install' https://github.com/electron-userland/electron-builder/issues/5633#issuecomment-779997166

mmaietta commented 2 months ago

I'm wondering if isUpdated is simply not defined. In your custom nsh script, can you try using these? I think the ifNot may be obscurring the actual value of isUpdated

!macro customUnInstall
    ${If} ${isUpdated}
        MessageBox MB_ICONEXCLAMATION|MB_OK "I'm inside customUnInstall -> isUpdated"
    ${Else}
        MessageBox MB_ICONEXCLAMATION|MB_OK "I'm inside customUnInstall -> not isUpdated"
    ${EndIf}
!macroend

!macro customUnInit
    ${If} ${isUpdated}
        MessageBox MB_ICONEXCLAMATION|MB_OK "I'm inside customUnInit -> isUpdated"
    ${Else}
        MessageBox MB_ICONEXCLAMATION|MB_OK "I'm inside customUnInit -> not isUpdated"
    ${EndIf}
!macroend
yoniabitbolkryon commented 2 months ago

@mmaietta I was able to see the message ("I'm inside customUnInstall -> isUpdated") from customUnInit, but after that the app says there was an error and I don't get to see customUnInstall message.

yoniabitbolkryon commented 2 months ago

I'm not too sure where isUpdated is being set, it's not being actually set to a value in any of the .nsh scripts. I'm wondering if it's a default value supplied by nsis scripts?

Here's an alternative route that could be used though! ${if} $1 != 'install' #5633 (comment)

where is $1 defined?

mmaietta commented 2 months ago

where is $1 defined?

See comment https://github.com/electron-userland/electron-builder/issues/5633#issuecomment-779997166

github-actions[bot] commented 3 weeks ago

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 30 days.