github.com/AlpineAIO/wails/v2@v2.0.0-beta.32.0.20240505041856-1047a8fa5fef/pkg/buildassets/build/windows/installer/project.nsi (about)

     1  Unicode true
     2  
     3  ####
     4  ## Please note: Template replacements don't work in this file. They are provided with default defines like
     5  ## mentioned underneath.
     6  ## If the keyword is not defined, "wails_tools.nsh" will populate them with the values from ProjectInfo.
     7  ## If they are defined here, "wails_tools.nsh" will not touch them. This allows to use this project.nsi manually
     8  ## from outside of Wails for debugging and development of the installer.
     9  ##
    10  ## For development first make a wails nsis build to populate the "wails_tools.nsh":
    11  ## > wails build --target windows/amd64 --nsis
    12  ## Then you can call makensis on this file with specifying the path to your binary:
    13  ## For a AMD64 only installer:
    14  ## > makensis -DARG_WAILS_AMD64_BINARY=..\..\bin\app.exe
    15  ## For a ARM64 only installer:
    16  ## > makensis -DARG_WAILS_ARM64_BINARY=..\..\bin\app.exe
    17  ## For a installer with both architectures:
    18  ## > makensis -DARG_WAILS_AMD64_BINARY=..\..\bin\app-amd64.exe -DARG_WAILS_ARM64_BINARY=..\..\bin\app-arm64.exe
    19  ####
    20  ## The following information is taken from the ProjectInfo file, but they can be overwritten here.
    21  ####
    22  ## !define INFO_PROJECTNAME    "MyProject" # Default "{{.Name}}"
    23  ## !define INFO_COMPANYNAME    "MyCompany" # Default "{{.Info.CompanyName}}"
    24  ## !define INFO_PRODUCTNAME    "MyProduct" # Default "{{.Info.ProductName}}"
    25  ## !define INFO_PRODUCTVERSION "1.0.0"     # Default "{{.Info.ProductVersion}}"
    26  ## !define INFO_COPYRIGHT      "Copyright" # Default "{{.Info.Copyright}}"
    27  ###
    28  ## !define PRODUCT_EXECUTABLE  "Application.exe"      # Default "${INFO_PROJECTNAME}.exe"
    29  ## !define UNINST_KEY_NAME     "UninstKeyInRegistry"  # Default "${INFO_COMPANYNAME}${INFO_PRODUCTNAME}"
    30  ####
    31  ## !define REQUEST_EXECUTION_LEVEL "admin"            # Default "admin"  see also https://nsis.sourceforge.io/Docs/Chapter4.html
    32  ####
    33  ## Include the wails tools
    34  ####
    35  !include "wails_tools.nsh"
    36  
    37  # The version information for this two must consist of 4 parts
    38  VIProductVersion "${INFO_PRODUCTVERSION}.0"
    39  VIFileVersion    "${INFO_PRODUCTVERSION}.0"
    40  
    41  VIAddVersionKey "CompanyName"     "${INFO_COMPANYNAME}"
    42  VIAddVersionKey "FileDescription" "${INFO_PRODUCTNAME} Installer"
    43  VIAddVersionKey "ProductVersion"  "${INFO_PRODUCTVERSION}"
    44  VIAddVersionKey "FileVersion"     "${INFO_PRODUCTVERSION}"
    45  VIAddVersionKey "LegalCopyright"  "${INFO_COPYRIGHT}"
    46  VIAddVersionKey "ProductName"     "${INFO_PRODUCTNAME}"
    47  
    48  # Enable HiDPI support. https://nsis.sourceforge.io/Reference/ManifestDPIAware
    49  ManifestDPIAware true
    50  
    51  !include "MUI.nsh"
    52  
    53  !define MUI_ICON "..\icon.ico"
    54  !define MUI_UNICON "..\icon.ico"
    55  # !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
    56  !define MUI_FINISHPAGE_NOAUTOCLOSE # Wait on the INSTFILES page so the user can take a look into the details of the installation steps
    57  !define MUI_ABORTWARNING # This will warn the user if they exit from the installer.
    58  
    59  !insertmacro MUI_PAGE_WELCOME # Welcome to the installer page.
    60  # !insertmacro MUI_PAGE_LICENSE "resources\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  
    65  !insertmacro MUI_UNPAGE_INSTFILES # Uinstalling page
    66  
    67  !insertmacro MUI_LANGUAGE "English" # Set the Language of the installer
    68  
    69  ## The following two statements can be used to sign the installer and the uninstaller. The path to the binaries are provided in %1
    70  #!uninstfinalize 'signtool --file "%1"'
    71  #!finalize 'signtool --file "%1"'
    72  
    73  Name "${INFO_PRODUCTNAME}"
    74  OutFile "..\..\bin\${INFO_PROJECTNAME}-${ARCH}-installer.exe" # Name of the installer's file.
    75  InstallDir "$PROGRAMFILES64\${INFO_COMPANYNAME}\${INFO_PRODUCTNAME}" # Default installing folder ($PROGRAMFILES is Program Files folder).
    76  ShowInstDetails show # This will always show the installation details.
    77  
    78  Function .onInit
    79     !insertmacro wails.checkArchitecture
    80  FunctionEnd
    81  
    82  Section
    83      !insertmacro wails.setShellContext
    84  
    85      !insertmacro wails.webview2runtime
    86  
    87      SetOutPath $INSTDIR
    88  
    89      !insertmacro wails.files
    90  
    91      CreateShortcut "$SMPROGRAMS\${INFO_PRODUCTNAME}.lnk" "$INSTDIR\${PRODUCT_EXECUTABLE}"
    92      CreateShortCut "$DESKTOP\${INFO_PRODUCTNAME}.lnk" "$INSTDIR\${PRODUCT_EXECUTABLE}"
    93  
    94      !insertmacro wails.associateFiles
    95      !insertmacro wails.associateCustomProtocols
    96  
    97      !insertmacro wails.writeUninstaller
    98  SectionEnd
    99  
   100  Section "uninstall"
   101      !insertmacro wails.setShellContext
   102  
   103      RMDir /r "$AppData\${PRODUCT_EXECUTABLE}" # Remove the WebView2 DataPath
   104  
   105      RMDir /r $INSTDIR
   106  
   107      Delete "$SMPROGRAMS\${INFO_PRODUCTNAME}.lnk"
   108      Delete "$DESKTOP\${INFO_PRODUCTNAME}.lnk"
   109  
   110      !insertmacro wails.unassociateFiles
   111      !insertmacro wails.unassociateCustomProtocols
   112  
   113      !insertmacro wails.deleteUninstaller
   114  SectionEnd