Skip to content

Function not referenced - zeroing code -> only when using custom scripts #9111

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

Open
GeorgeFlorian opened this issue May 16, 2025 · 0 comments

Comments

@GeorgeFlorian
Copy link

GeorgeFlorian commented May 16, 2025

What is the correct way to include or use Functions in custom macros like customInstall ?

I've seen similar issues that have been ignored along the years and I do not understand why:
#1122
#1231
#1239
#3871
#4777

This is a real issue !

The docs do not mention how to include functions when using custom electron scripts.
Please answer.

Thank you.

I include the script like this in package.json : "include": "build/installer.nsh",

I have defined Function SemanticVersionCompare in a script file called version-check.nsh:

; version-check.nsh
Function SemanticVersionCompare
FunctionEnd

!macro SemanticVersionCompare Version1 Version2 Result
  Push "${Version1}"
  Push "${Version2}"
  Call SemanticVersionCompare
  Pop ${Result}
!macroend

!macro CheckVersion
    !insertmacro SemanticVersionCompare "${VERSION}" "$0" $R0
    ; ... other stuff ...
!macroend

installer.nsh

!include "version-check.nsh"

!macro customInstall
  !insertmacro CheckVersion

  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APP_ID}" "DisplayVersion" "${VERSION}"
  !insertmacro firewallRuleInstall

  WriteUninstaller "$INSTDIR\uninstaller.exe"
!macroend

I have tried these tricks to no avail:

; adding dummy call to the end of installer script
Function __keep_SemanticVersionCompare
  ; Dummy call to trick NSIS compiler into keeping the function
  Call SemanticVersionCompare
FunctionEnd

; declare Function inside customInit
!macro customInit
  Function SemanticVersionCompare
    ; ...
  FunctionEnd
!macroend

; insert CheckVersion in customInit
!macro customInit
  !insertmacro CheckVersion
!macroend

; wrap function in ifndef BUILD_UNINSTALLER block
; also wrap it in BUILD_INSTALLER block
!ifndef BUILD_UNINSTALLER
  Function SemanticVersionCompare
!endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant