farmcontrol-server/packaging/windows/farmcontrol-server.nsi
Tom Butcher 0aa26eab66
Some checks failed
farmcontrol/farmcontrol-server/pipeline/head There was a failure building this commit
Enhance Windows installer with MSI support and shortcut creation
- Updated farmcontrol-server.nsi to include desktop and Start Menu shortcut creation.
- Added new macros in installer.nsh for managing shortcuts during installation and uninstallation.
- Introduced build-windows-msi.ps1 script for generating MSI installers, integrating with existing build processes.
- Modified finalize-desktop-artifacts.mjs to call the new MSI build script, ensuring proper artifact generation.
2026-08-01 22:21:49 +01:00

87 lines
2.7 KiB
NSIS

!include "MUI2.nsh"
!include "LogicLib.nsh"
!include "installer.nsh"
!ifndef OUTFILE
!define OUTFILE "farmcontrol-server-installer.exe"
!endif
!ifndef VERSION
!define VERSION "1.0.0"
!endif
!ifndef APP_SOURCE_DIR
!define APP_SOURCE_DIR "."
!endif
Name "Farm Control Server"
OutFile "${OUTFILE}"
InstallDir "$PROGRAMFILES64\Farm Control Server"
InstallDirRegKey HKLM "Software\Tom Butcher\Farm Control Server" "InstallDir"
RequestExecutionLevel admin
!define MUI_ABORTWARNING
!define MUI_ICON "${NSISDIR}\Contrib\Graphics\Icons\modern-install.ico"
!define MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\modern-uninstall.ico"
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES
!insertmacro MUI_LANGUAGE "English"
Function .onInit
${If} ${Silent}
SetAutoClose true
${EndIf}
FunctionEnd
Section "Farm Control Server" SecMain
SectionIn RO
SetOutPath $INSTDIR
File /r "${APP_SOURCE_DIR}\*"
!insertmacro customInstall
WriteRegStr HKLM "Software\Tom Butcher\Farm Control Server" "InstallDir" $INSTDIR
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Farm Control Server" \
"DisplayName" "Farm Control Server"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Farm Control Server" \
"DisplayVersion" "${VERSION}"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Farm Control Server" \
"Publisher" "Tom Butcher"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Farm Control Server" \
"UninstallString" "$INSTDIR\Uninstall.exe"
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Farm Control Server" \
"NoModify" 1
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Farm Control Server" \
"NoRepair" 1
WriteUninstaller "$INSTDIR\Uninstall.exe"
SectionEnd
Section "Desktop shortcut" SecDesktop
!insertmacro createDesktopShortcut
SectionEnd
Section "Start Menu shortcut" SecStartMenu
!insertmacro createStartMenuShortcut
SectionEnd
!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
!insertmacro MUI_DESCRIPTION_TEXT ${SecMain} "Install Farm Control Server."
!insertmacro MUI_DESCRIPTION_TEXT ${SecDesktop} "Create a shortcut on the Desktop."
!insertmacro MUI_DESCRIPTION_TEXT ${SecStartMenu} "Create a shortcut in the Start Menu."
!insertmacro MUI_FUNCTION_DESCRIPTION_END
Section "Uninstall"
!insertmacro customUnInstall
Delete "$INSTDIR\Uninstall.exe"
RMDir /r "$INSTDIR"
DeleteRegKey HKLM "Software\Tom Butcher\Farm Control Server"
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Farm Control Server"
SectionEnd