project.nsi 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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 with the values from ProjectInfo.
  6. ## If they are defined here, "wails_tools.nsh" will not touch them. This allows 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 ProjectInfo file, but they can be overwritten here.
  20. ####
  21. ## !define INFO_PROJECTNAME "MyProject" # Default "{{.Name}}"
  22. ## !define INFO_COMPANYNAME "MyCompany" # Default "{{.Info.CompanyName}}"
  23. ## !define INFO_PRODUCTNAME "MyProduct" # Default "{{.Info.ProductName}}"
  24. ## !define INFO_PRODUCTVERSION "1.0.0" # Default "{{.Info.ProductVersion}}"
  25. ## !define INFO_COPYRIGHT "Copyright" # Default "{{.Info.Copyright}}"
  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. ####
  32. ## Include the wails tools
  33. ####
  34. !include "wails_tools.nsh"
  35. # The version information for this two must consist of 4 parts
  36. VIProductVersion "${INFO_PRODUCTVERSION}.0"
  37. VIFileVersion "${INFO_PRODUCTVERSION}.0"
  38. VIAddVersionKey "CompanyName" "${INFO_COMPANYNAME}"
  39. VIAddVersionKey "FileDescription" "${INFO_PRODUCTNAME} Installer"
  40. VIAddVersionKey "ProductVersion" "${INFO_PRODUCTVERSION}"
  41. VIAddVersionKey "FileVersion" "${INFO_PRODUCTVERSION}"
  42. VIAddVersionKey "LegalCopyright" "${INFO_COPYRIGHT}"
  43. VIAddVersionKey "ProductName" "${INFO_PRODUCTNAME}"
  44. # Enable HiDPI support. https://nsis.sourceforge.io/Reference/ManifestDPIAware
  45. ManifestDPIAware true
  46. !include "MUI.nsh"
  47. !define MUI_ICON "..\icon.ico"
  48. !define MUI_UNICON "..\icon.ico"
  49. # !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
  50. !define MUI_FINISHPAGE_NOAUTOCLOSE # Wait on the INSTFILES page so the user can take a look into the details of the installation steps
  51. !define MUI_ABORTWARNING # This will warn the user if they exit from the installer.
  52. !insertmacro MUI_PAGE_WELCOME # Welcome to the installer page.
  53. # !insertmacro MUI_PAGE_LICENSE "resources\eula.txt" # Adds a EULA page to the installer
  54. !insertmacro MUI_PAGE_DIRECTORY # In which folder install page.
  55. !insertmacro MUI_PAGE_INSTFILES # Installing page.
  56. !insertmacro MUI_PAGE_FINISH # Finished installation page.
  57. !insertmacro MUI_UNPAGE_INSTFILES # Uinstalling page
  58. !insertmacro MUI_LANGUAGE "English" # Set the Language of the installer
  59. ## The following two statements can be used to sign the installer and the uninstaller. The path to the binaries are provided in %1
  60. #!uninstfinalize 'signtool --file "%1"'
  61. #!finalize 'signtool --file "%1"'
  62. Name "${INFO_PRODUCTNAME}"
  63. OutFile "..\..\bin\${INFO_PROJECTNAME}-${ARCH}-installer.exe" # Name of the installer's file.
  64. InstallDir "$PROGRAMFILES64\${INFO_COMPANYNAME}\${INFO_PRODUCTNAME}" # Default installing folder ($PROGRAMFILES is Program Files folder).
  65. ShowInstDetails show # This will always show the installation details.
  66. Function .onInit
  67. !insertmacro wails.checkArchitecture
  68. FunctionEnd
  69. Section
  70. !insertmacro wails.setShellContext
  71. !insertmacro wails.webview2runtime
  72. SetOutPath $INSTDIR
  73. !insertmacro wails.files
  74. CreateShortcut "$SMPROGRAMS\${INFO_PRODUCTNAME}.lnk" "$INSTDIR\${PRODUCT_EXECUTABLE}"
  75. CreateShortCut "$DESKTOP\${INFO_PRODUCTNAME}.lnk" "$INSTDIR\${PRODUCT_EXECUTABLE}"
  76. !insertmacro wails.associateFiles
  77. !insertmacro wails.associateCustomProtocols
  78. !insertmacro wails.writeUninstaller
  79. SectionEnd
  80. Section "uninstall"
  81. !insertmacro wails.setShellContext
  82. RMDir /r "$AppData\${PRODUCT_EXECUTABLE}" # Remove the WebView2 DataPath
  83. RMDir /r $INSTDIR
  84. Delete "$SMPROGRAMS\${INFO_PRODUCTNAME}.lnk"
  85. Delete "$DESKTOP\${INFO_PRODUCTNAME}.lnk"
  86. !insertmacro wails.unassociateFiles
  87. !insertmacro wails.unassociateCustomProtocols
  88. !insertmacro wails.deleteUninstaller
  89. SectionEnd