Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

customInstall wrong ${isUpdated} value #8365

Open
yoniabitbolkryon opened this issue Jul 21, 2024 · 6 comments
Open

customInstall wrong ${isUpdated} value #8365

yoniabitbolkryon opened this issue Jul 21, 2024 · 6 comments
Labels

Comments

@yoniabitbolkryon
Copy link

yoniabitbolkryon commented Jul 21, 2024

  • Electron-Builder Version: v24.13.3

  • Node Version: v20.10.0

  • Electron Version: v28.0.0

  • Electron Type (current, beta, nightly): current

  • Target: win nsis

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
Copy link
Collaborator

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)

@mmaietta
Copy link
Collaborator

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
Copy link
Author

@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
Copy link
Author

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
Copy link
Collaborator

where is $1 defined?

See comment #5633 (comment)

Copy link
Contributor

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.

@github-actions github-actions bot added the Stale label Sep 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants