project.nsi 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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 "my-project" # Default "myapp"
  22. ## !define INFO_COMPANYNAME "My Company" # Default "TengTu Studio"
  23. ## !define INFO_PRODUCTNAME "My Product Name" # Default "My Product"
  24. ## !define INFO_PRODUCTVERSION "1.0.0" # Default "0.1.0"
  25. ## !define INFO_COPYRIGHT "(c) Now, My Company" # Default "© 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. ####
  30. ## !define REQUEST_EXECUTION_LEVEL "admin" # Default "admin" see also https://nsis.sourceforge.io/Docs/Chapter4.html
  31. ## !define WAILS_INSTALL_SCOPE "user" # Default "machine" - set to "user" for per-user install ($LOCALAPPDATA) without UAC prompt
  32. ####
  33. ## Include the wails tools
  34. ####
  35. !include "wails_tools.nsh"
  36. # The version information for this two must consist of 4 parts
  37. VIProductVersion "${INFO_PRODUCTVERSION}.0"
  38. VIFileVersion "${INFO_PRODUCTVERSION}.0"
  39. VIAddVersionKey "CompanyName" "${INFO_COMPANYNAME}"
  40. VIAddVersionKey "FileDescription" "${INFO_PRODUCTNAME} Installer"
  41. VIAddVersionKey "ProductVersion" "${INFO_PRODUCTVERSION}"
  42. VIAddVersionKey "FileVersion" "${INFO_PRODUCTVERSION}"
  43. VIAddVersionKey "LegalCopyright" "${INFO_COPYRIGHT}"
  44. VIAddVersionKey "ProductName" "${INFO_PRODUCTNAME}"
  45. # Enable HiDPI support. https://nsis.sourceforge.io/Reference/ManifestDPIAware
  46. ManifestDPIAware true
  47. !include "MUI.nsh"
  48. !define MUI_ICON "..\icon.ico"
  49. !define MUI_UNICON "..\icon.ico"
  50. # !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
  51. !define MUI_FINISHPAGE_NOAUTOCLOSE # Wait on the INSTFILES page so the user can take a look into the details of the installation steps
  52. !define MUI_ABORTWARNING # This will warn the user if they exit from the installer.
  53. !insertmacro MUI_PAGE_WELCOME # Welcome to the installer page.
  54. !insertmacro MUI_PAGE_LICENSE "eula.txt" # Adds a EULA page to the installer
  55. !insertmacro MUI_PAGE_DIRECTORY # In which folder install page.
  56. !insertmacro MUI_PAGE_INSTFILES # Installing page.
  57. !insertmacro MUI_PAGE_FINISH # Finished installation page.
  58. !insertmacro MUI_UNPAGE_INSTFILES # Uninstalling page
  59. !insertmacro MUI_LANGUAGE "SimpChinese" # Set the Language of the installer
  60. ## The following two statements can be used to sign the installer and the uninstaller. The path to the binaries are provided in %1
  61. #!uninstfinalize 'signtool --file "%1"'
  62. #!finalize 'signtool --file "%1"'
  63. Name "${INFO_PRODUCTNAME}"
  64. OutFile "..\..\..\bin\${INFO_PROJECTNAME}-${ARCH}-installer.exe" # Name of the installer's file.
  65. !if "${WAILS_INSTALL_SCOPE}" == "user"
  66. InstallDir "$LOCALAPPDATA\Programs\${INFO_PRODUCTNAME}"
  67. !else
  68. InstallDir "$PROGRAMFILES64\${INFO_COMPANYNAME}\${INFO_PRODUCTNAME}"
  69. !endif
  70. ShowInstDetails show # This will always show the installation details.
  71. Function .onInit
  72. !insertmacro wails.checkArchitecture
  73. FunctionEnd
  74. Section
  75. !insertmacro wails.setShellContext
  76. !insertmacro wails.webview2runtime
  77. SetOutPath $INSTDIR
  78. !insertmacro wails.files
  79. CreateShortcut "$SMPROGRAMS\${INFO_PRODUCTNAME}.lnk" "$INSTDIR\${PRODUCT_EXECUTABLE}"
  80. CreateShortCut "$DESKTOP\${INFO_PRODUCTNAME}.lnk" "$INSTDIR\${PRODUCT_EXECUTABLE}"
  81. !insertmacro wails.associateFiles
  82. !insertmacro wails.associateCustomProtocols
  83. !insertmacro wails.writeUninstaller
  84. SectionEnd
  85. Section "uninstall"
  86. !insertmacro wails.setShellContext
  87. RMDir /r "$AppData\${PRODUCT_EXECUTABLE}" # Remove the WebView2 DataPath
  88. RMDir /r $INSTDIR
  89. Delete "$SMPROGRAMS\${INFO_PRODUCTNAME}.lnk"
  90. Delete "$DESKTOP\${INFO_PRODUCTNAME}.lnk"
  91. !insertmacro wails.unassociateFiles
  92. !insertmacro wails.unassociateCustomProtocols
  93. !insertmacro wails.deleteUninstaller
  94. SectionEnd