1
0

project.nsi 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. Unicode true
  2. ####
  3. ## Please note: Template replacements don't work in this file. They are provided with default defines like
  4. ## mentioned underneath.
  5. ## If the keyword is not defined, "wails_tools.nsh" will populate them.
  6. ## If they are defined here, "wails_tools.nsh" will not touch them. This allows you to use this project.nsi manually
  7. ## from outside of Wails for debugging and development of the installer.
  8. ##
  9. ## For development first make a wails nsis build to populate the "wails_tools.nsh":
  10. ## > wails build --target windows/amd64 --nsis
  11. ## Then you can call makensis on this file with specifying the path to your binary:
  12. ## For a AMD64 only installer:
  13. ## > makensis -DARG_WAILS_AMD64_BINARY=..\..\bin\app.exe
  14. ## For a ARM64 only installer:
  15. ## > makensis -DARG_WAILS_ARM64_BINARY=..\..\bin\app.exe
  16. ## For a installer with both architectures:
  17. ## > makensis -DARG_WAILS_AMD64_BINARY=..\..\bin\app-amd64.exe -DARG_WAILS_ARM64_BINARY=..\..\bin\app-arm64.exe
  18. ####
  19. ## The following information is taken from the wails_tools.nsh file, but they can be overwritten here.
  20. ####
  21. !define INFO_PROJECTNAME "TengTu Toolbox"
  22. !define INFO_COMPANYNAME "TengTu Studio"
  23. !define INFO_PRODUCTNAME "TengTu Toolbox"
  24. !define INFO_PRODUCTVERSION "0.1.8.0"
  25. !define INFO_COPYRIGHT "(c) 2026, TengTu Studio"
  26. ###
  27. ## !define PRODUCT_EXECUTABLE "Application.exe" # Default "${INFO_PROJECTNAME}.exe"
  28. ## !define UNINST_KEY_NAME "UninstKeyInRegistry" # Default "${INFO_COMPANYNAME}${INFO_PRODUCTNAME}"
  29. # Standalone service binary (built with -tags service, no GUI). Installed alongside
  30. # the main app so the Service page registers it, keeping service memory low.
  31. # Kept in ASCII on purpose: makensis reads this file as ACP, Chinese chars break it.
  32. !ifndef SERVICE_EXECUTABLE
  33. !define SERVICE_EXECUTABLE "${INFO_PROJECTNAME}-service.exe"
  34. !endif
  35. ####
  36. ## !define REQUEST_EXECUTION_LEVEL "admin" # Default "admin" see also https://nsis.sourceforge.io/Docs/Chapter4.html
  37. ## !define WAILS_INSTALL_SCOPE "user" # Default "machine" - set to "user" for per-user install ($LOCALAPPDATA) without UAC prompt
  38. ####
  39. ## Include the wails tools
  40. ####
  41. !include "wails_tools.nsh"
  42. # The version information for this two must consist of 4 parts
  43. VIProductVersion "${INFO_PRODUCTVERSION}.0"
  44. VIFileVersion "${INFO_PRODUCTVERSION}.0"
  45. VIAddVersionKey "CompanyName" "${INFO_COMPANYNAME}"
  46. VIAddVersionKey "FileDescription" "${INFO_PRODUCTNAME} Installer"
  47. VIAddVersionKey "ProductVersion" "${INFO_PRODUCTVERSION}"
  48. VIAddVersionKey "FileVersion" "${INFO_PRODUCTVERSION}"
  49. VIAddVersionKey "LegalCopyright" "${INFO_COPYRIGHT}"
  50. VIAddVersionKey "ProductName" "${INFO_PRODUCTNAME}"
  51. # Enable HiDPI support. https://nsis.sourceforge.io/Reference/ManifestDPIAware
  52. ManifestDPIAware true
  53. !include "MUI.nsh"
  54. !define MUI_ICON "..\icon.ico"
  55. !define MUI_UNICON "..\icon.ico"
  56. # !define MUI_WELCOMEFINISHPAGE_BITMAP "resources\leftimage.bmp" #Include this to add a bitmap on the left side of the Welcome Page. Must be a size of 164x314
  57. !define MUI_FINISHPAGE_NOAUTOCLOSE # Wait on the INSTFILES page so the user can take a look into the details of the installation steps
  58. !define MUI_ABORTWARNING # This will warn the user if they exit from the installer.
  59. !insertmacro MUI_PAGE_WELCOME # Welcome to the installer page.
  60. !insertmacro MUI_PAGE_LICENSE "eula.txt" # Adds a EULA page to the installer
  61. !insertmacro MUI_PAGE_DIRECTORY # In which folder install page.
  62. !insertmacro MUI_PAGE_INSTFILES # Installing page.
  63. !insertmacro MUI_PAGE_FINISH # Finished installation page.
  64. !insertmacro MUI_UNPAGE_INSTFILES # Uninstalling page
  65. !insertmacro MUI_LANGUAGE "SimpChinese" # Set the Language of the installer
  66. ## The following two statements can be used to sign the installer and the uninstaller. The path to the binaries are provided in %1
  67. #!uninstfinalize 'signtool --file "%1"'
  68. #!finalize 'signtool --file "%1"'
  69. Name "${INFO_PRODUCTNAME}"
  70. OutFile "..\..\..\bin\${INFO_PROJECTNAME}-${ARCH}-installer.exe" # Name of the installer's file.
  71. !if "${WAILS_INSTALL_SCOPE}" == "user"
  72. InstallDir "$LOCALAPPDATA\Programs\${INFO_PRODUCTNAME}"
  73. !else
  74. InstallDir "$PROGRAMFILES64\${INFO_COMPANYNAME}\${INFO_PRODUCTNAME}"
  75. !endif
  76. ShowInstDetails show # This will always show the installation details.
  77. Function .onInit
  78. !insertmacro wails.checkArchitecture
  79. FunctionEnd
  80. Section
  81. !insertmacro wails.setShellContext
  82. !insertmacro wails.webview2runtime
  83. SetOutPath $INSTDIR
  84. !insertmacro wails.files
  85. ; Standalone service binary (built with -tags service, no GUI): installed alongside
  86. ; the main app so the Service page registers it, keeping service memory low.
  87. ; Note: SERVICE_EXECUTABLE contains a space, so quote the whole /oname= arg
  88. !ifdef ARG_WAILS_SERVICE_BINARY
  89. File "/oname=${SERVICE_EXECUTABLE}" "${ARG_WAILS_SERVICE_BINARY}"
  90. !endif
  91. CreateShortcut "$SMPROGRAMS\${INFO_PRODUCTNAME}.lnk" "$INSTDIR\${PRODUCT_EXECUTABLE}"
  92. CreateShortCut "$DESKTOP\${INFO_PRODUCTNAME}.lnk" "$INSTDIR\${PRODUCT_EXECUTABLE}"
  93. !insertmacro wails.associateFiles
  94. !insertmacro wails.associateCustomProtocols
  95. !insertmacro wails.writeUninstaller
  96. SectionEnd
  97. Section "uninstall"
  98. !insertmacro wails.setShellContext
  99. RMDir /r "$AppData\${PRODUCT_EXECUTABLE}" # Remove the WebView2 DataPath
  100. RMDir /r $INSTDIR
  101. Delete "$SMPROGRAMS\${INFO_PRODUCTNAME}.lnk"
  102. Delete "$DESKTOP\${INFO_PRODUCTNAME}.lnk"
  103. !insertmacro wails.unassociateFiles
  104. !insertmacro wails.unassociateCustomProtocols
  105. !insertmacro wails.deleteUninstaller
  106. SectionEnd