From f63b04d25b6477ae1aa3a9d594462bdbe1f9c78d Mon Sep 17 00:00:00 2001 From: Paul Schneider Date: Sun, 18 Oct 2026 22:29:03 +0100 Subject: [PATCH] feat(postit): add per-user Windows NSIS installer Package the self-contained Windows x64 publication, register the postit URI scheme, and provide a Start menu shortcut and uninstaller. Document generation and update the changelog. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .gitignore | 1 + CHANGELOG.md | 5 ++ INSTALL.md | 47 +++++++++++++++ contrib/Windows/postit.nsi | 114 +++++++++++++++++++++++++++++++++++++ 4 files changed, 167 insertions(+) create mode 100644 contrib/Windows/postit.nsi diff --git a/.gitignore b/.gitignore index 57f13079f..4b32182a0 100644 --- a/.gitignore +++ b/.gitignore @@ -34,6 +34,7 @@ appsettings-*.*.json !src/Yavsc.Org/appsettings-org.Testing.json generated/ +/contrib/Windows/PostIt-*-Setup.exe *.tmp tmp/ DataDir/ diff --git a/CHANGELOG.md b/CHANGELOG.md index b2219e41b..8567c5899 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,11 @@ ### Added +* [PostIt.Desktop] Installeur NSIS Windows x64 par utilisateur, sans + elevation : publication autonome, raccourci du menu Demarrer, + protocole `postit://` pour la connexion et desinstallation via Windows. + Instructions de generation ajoutees dans `INSTALL.md`. + * [PostIt, Yavsc.Api] Portage des outils des contrôleurs web d’administration : tableau de bord, rôles et affectations, clients OIDC (paramètres, collections et secrets), scopes API et modèles de courriels. diff --git a/INSTALL.md b/INSTALL.md index d7315074a..a836c6611 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -29,6 +29,53 @@ dotnet publish -c Release and then, install the app, from the `src/PostIt/PostIt.Android/bin/Release/net10.0/PostIt.apk` +## PostIt.Desktop on Windows (per-user installer) + +Build prerequisites: the .NET 10 SDK and NSIS 3 (with its standard +Modern UI 2 includes). From the repository root, publish a self-contained +Windows x64 application, then package the **entire** publish directory: + +```powershell +dotnet publish src/PostIt/PostIt.Desktop/PostIt.Desktop.csproj -c Release -r win-x64 --self-contained true -p:PublishSingleFile=false +makensis /DAPP_VERSION=1.1.0-estimate.1 contrib/Windows/postit.nsi +``` + +Set `APP_VERSION` to the version of the published application (the +`Version` property in `PostIt.Desktop.csproj`). NSIS requires this value; +it is used in the installer filename and Windows' installed-apps list. +On Linux, use `makensis -DAPP_VERSION=1.1.0-estimate.1 contrib/Windows/postit.nsi` +instead. Cross-publishing uses the same `dotnet publish` command. +If `makensis` is not on `PATH` on Windows, invoke the executable from +the NSIS installation directory. + +The result is `contrib/Windows/PostIt--win-x64-Setup.exe`. +NSIS also accepts `PUBLISH_DIR` (an absolute path to a different +**win-x64** publish directory) and `OUTPUT_FILE` (the output executable +path), with the same `/DNAME=value` or `-DNAME=value` syntax. Quote an +entire define argument when its value contains spaces. + +The installer does not request elevation or install a shared .NET runtime. +It installs in `%LOCALAPPDATA%\Yavsc\PostIt.Desktop`, creates a Start menu +shortcut for the current user and registers `postit://` in +`HKCU\Software\Classes` so browser-based sign-in returns to PostIt. +Windows' installed-apps list provides the uninstaller. Close PostIt before +installing an update or uninstalling it. + +The `app` subdirectory is reserved for published application files and is +removed recursively on uninstall. User settings and tokens stored outside +this directory are preserved. Reinstalling uses the recorded installation +directory and overwrites the packaged files. + +The self-contained publication includes .NET, but does **not** add native +LibVLC libraries: video playback still requires a compatible Windows x64 +LibVLC installation. PostIt reports an unavailable video player and offers +the system browser as an alternative. + +Before distributing a release, test installation, startup, the `postit://` +login callback, updating and uninstallation on Windows with a standard +(non-administrator) account. Installer compilation alone does not validate +these Windows runtime behaviours. + ## Resources System resources needed to install. diff --git a/contrib/Windows/postit.nsi b/contrib/Windows/postit.nsi new file mode 100644 index 000000000..b6399a611 --- /dev/null +++ b/contrib/Windows/postit.nsi @@ -0,0 +1,114 @@ +Unicode true +RequestExecutionLevel user +SetCompressor /SOLID lzma + +!include "MUI2.nsh" +!include "LogicLib.nsh" +!include "x64.nsh" + +!define APPNAME "PostIt.Desktop" +!define APP_EXE "PostIt.Desktop.exe" +!define PUBLISHER "Yavsc" +!define UNINSTALL_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}" +!define PROTOCOL_KEY "Software\Classes\postit" + +!ifndef APP_VERSION + !error "Define APP_VERSION with /DAPP_VERSION=... (Windows) or -DAPP_VERSION=... (Linux)." +!endif +!ifndef PUBLISH_DIR + !define PUBLISH_DIR "..\..\src\PostIt\PostIt.Desktop\bin\Release\net10.0\win-x64\publish" +!endif +!ifndef OUTPUT_FILE + !define OUTPUT_FILE "PostIt-${APP_VERSION}-win-x64-Setup.exe" +!endif +!if ! /FileExists "${PUBLISH_DIR}\${APP_EXE}" + !error "Publish PostIt.Desktop for win-x64 before compiling the installer (see INSTALL.md)." +!endif + +Name "${APPNAME}" +OutFile "${OUTPUT_FILE}" +InstallDir "$LOCALAPPDATA\${PUBLISHER}\${APPNAME}" +InstallDirRegKey HKCU "${UNINSTALL_KEY}" "InstallLocation" +ShowInstDetails show +ShowUninstDetails show + +!define MUI_ABORTWARNING +!define MUI_ICON "..\..\src\PostIt\PostIt\Assets\yavsc-logo.ico" +!insertmacro MUI_PAGE_WELCOME +!insertmacro MUI_PAGE_INSTFILES +!insertmacro MUI_PAGE_FINISH +!insertmacro MUI_UNPAGE_CONFIRM +!insertmacro MUI_UNPAGE_INSTFILES +!insertmacro MUI_LANGUAGE "French" + +Function .onInit + SetShellVarContext current + ${IfNot} ${RunningX64} + MessageBox MB_OK|MB_ICONSTOP "Cette version de PostIt.Desktop requiert Windows 64 bits." /SD IDOK + Abort + ${EndIf} +FunctionEnd + +Function un.onInit + SetShellVarContext current +FunctionEnd + +Section "PostIt.Desktop" + ; Keep the recursive payload separate from user data and the uninstaller. + ClearErrors + SetOutPath "$INSTDIR\app" + ${If} ${Errors} + MessageBox MB_OK|MB_ICONSTOP "Impossible de creer le dossier d'installation. Verifiez les droits d'ecriture, puis relancez l'installation." /SD IDOK + Abort + ${EndIf} + File /r "${PUBLISH_DIR}\*" + WriteUninstaller "$INSTDIR\uninstall.exe" + ${If} ${Errors} + MessageBox MB_OK|MB_ICONSTOP "Installation impossible. Fermez PostIt.Desktop et verifiez les droits d'ecriture et l'espace disque, puis relancez l'installation." /SD IDOK + Abort + ${EndIf} + + ClearErrors + CreateDirectory "$SMPROGRAMS\${PUBLISHER}" + CreateShortcut "$SMPROGRAMS\${PUBLISHER}\${APPNAME}.lnk" "$INSTDIR\app\${APP_EXE}" + + WriteRegStr HKCU "${PROTOCOL_KEY}" "" "URL:PostIt" + WriteRegStr HKCU "${PROTOCOL_KEY}" "URL Protocol" "" + WriteRegStr HKCU "${PROTOCOL_KEY}\DefaultIcon" "" '"$INSTDIR\app\${APP_EXE}",0' + WriteRegStr HKCU "${PROTOCOL_KEY}\shell\open\command" "" '"$INSTDIR\app\${APP_EXE}" "%1"' + + WriteRegStr HKCU "${UNINSTALL_KEY}" "DisplayName" "${APPNAME}" + WriteRegStr HKCU "${UNINSTALL_KEY}" "DisplayVersion" "${APP_VERSION}" + WriteRegStr HKCU "${UNINSTALL_KEY}" "Publisher" "${PUBLISHER}" + WriteRegStr HKCU "${UNINSTALL_KEY}" "DisplayIcon" '"$INSTDIR\app\${APP_EXE}",0' + WriteRegStr HKCU "${UNINSTALL_KEY}" "UninstallString" '"$INSTDIR\uninstall.exe"' + WriteRegStr HKCU "${UNINSTALL_KEY}" "QuietUninstallString" '"$INSTDIR\uninstall.exe" /S' + WriteRegStr HKCU "${UNINSTALL_KEY}" "InstallLocation" "$INSTDIR" + WriteRegDWORD HKCU "${UNINSTALL_KEY}" "NoModify" 1 + WriteRegDWORD HKCU "${UNINSTALL_KEY}" "NoRepair" 1 + ${If} ${Errors} + MessageBox MB_OK|MB_ICONSTOP "Impossible de creer les raccourcis ou les entrees du registre utilisateur. Relancez l'installation." /SD IDOK + Abort + ${EndIf} +SectionEnd + +Section "Uninstall" + SetOutPath "$TEMP" + ClearErrors + RMDir /r "$INSTDIR\app" + ${If} ${Errors} + MessageBox MB_OK|MB_ICONSTOP "Des fichiers n'ont pas pu etre supprimes. Fermez PostIt.Desktop, puis relancez la desinstallation." /SD IDOK + Abort + ${EndIf} + + ; Do not remove a protocol handler subsequently registered by another install. + ReadRegStr $0 HKCU "${PROTOCOL_KEY}\shell\open\command" "" + ${If} $0 == '"$INSTDIR\app\${APP_EXE}" "%1"' + DeleteRegKey HKCU "${PROTOCOL_KEY}" + ${EndIf} + Delete "$SMPROGRAMS\${PUBLISHER}\${APPNAME}.lnk" + RMDir "$SMPROGRAMS\${PUBLISHER}" + DeleteRegKey HKCU "${UNINSTALL_KEY}" + Delete "$INSTDIR\uninstall.exe" + RMDir "$INSTDIR" +SectionEnd