diff --git a/agent/installer/SUIVI_INSTALLER.md b/agent/installer/SUIVI_INSTALLER.md new file mode 100644 index 0000000..8256b17 --- /dev/null +++ b/agent/installer/SUIVI_INSTALLER.md @@ -0,0 +1,106 @@ +# Feuille de route — Installateur studioE5 Agent + +## Objectif + +Fournir un **installateur professionnel Windows** pour studioE5 Agent, guidé pas à pas, qui gère les prérequis (WSL2 / Podman) et propose une désinstallation complète. + +## Architecture choisie + +- **Wizard C# Windows Forms (.NET 8)** : `setup-wizard/` + - Détecte les prérequis. + - Installe WSL2 si besoin (avec reprise après redémarrage via `RunOnce`). + - Installe Podman depuis le MSI officiel. + - Initialise et démarre la machine Podman. + - Lance le package Inno Setup de studioE5 Agent. + - Mode désinstallation via `/uninstall`. +- **Package agent (Inno Setup)** : `studioE5-agent.iss` + - Installe `studioE5-agent.exe` + binaires Tailscale. + - Crée les raccourcis. + - Gère la désinstallation. + +## État actuel + +### ✅ Réalisé + +- Wizard C# avec 7 étapes guidées. +- Détection des prérequis : Windows, RAM, disque, WSL2, Podman. +- Installation WSL2 avec redémarrage + reprise automatique. +- Installation Podman via MSI bundlé. +- Configuration Podman (`machine init` + `machine start`). +- Lancement du package Inno Setup agent. +- Mode désinstallation complet. +- Script Inno Setup de base pour l’agent. + +### 🔄 En cours / À tester + +- Compilation et test du wizard sur Windows. +- Packaging final (wizard + MSI Podman + setup agent) en un seul dossier distribuable. + +### ⏳ À venir + +- Signature de l’exécutable pour éviter les alertes SmartScreen. +- Support macOS et Linux. +- Installateur silencieux possible pour déploiement GPO. + +## Build du wizard + +### Prérequis + +- Windows 10/11 +- .NET 8 SDK +- Inno Setup 6 (pour générer `studioE5-agent-setup.exe`) + +### Fichiers à placer + +Dans `setup-wizard/Resources/` : + +```text +podman-installer-windows-amd64.msi +studioE5-agent-setup.exe +``` + +### Commande + +```powershell +cd setup-wizard +dotnet publish -c Release -r win-x64 --self-contained true /p:PublishSingleFile=true +``` + +### Sortie + +```text +setup-wizard\bin\Release\net8.0-windows\win-x64\publish\StudioE5-SetupWizard.exe +``` + +## Build du package agent (Inno Setup) + +Structure attendue : + +```text +agent/ +├── studioE5-agent.exe +├── tailscale-bin/ +│ └── windows/ +│ ├── tailscale.exe +│ ├── tailscaled.exe +│ └── wintun.dll +└── installer/ + └── studioE5-agent.iss +``` + +Ouvrir `studioE5-agent.iss` avec Inno Setup Compiler et compiler (`Ctrl+F9`). + +Le fichier généré se trouve dans `installer-output/`. + +## Notes importantes + +- Le wizard doit être exécuté **en administrateur**. +- L’installation de WSL2 nécessite un **redémarrage** de l’ordinateur. +- Le MSI Podman officiel pour Windows est `podman-installer-windows-amd64.msi`. +- Pour la désinstallation, le MSI Podman doit être présent dans `Resources/`. + +## Liens utiles + +- Releases Podman : +- Inno Setup : +- .NET 8 SDK : diff --git a/agent/installer/setup-wizard/MainForm.cs b/agent/installer/setup-wizard/MainForm.cs index 5e9a5c4..128c5bd 100644 --- a/agent/installer/setup-wizard/MainForm.cs +++ b/agent/installer/setup-wizard/MainForm.cs @@ -412,9 +412,9 @@ public partial class MainForm : Form try { - var msiPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) ?? ".", "Resources", "podman-setup.msi"); + var msiPath = Path.Combine(AppContext.BaseDirectory, "Resources", "podman-installer-windows-amd64.msi"); if (!File.Exists(msiPath)) - throw new FileNotFoundException("Le fichier podman-setup.msi est introuvable. Vérifiez qu'il est bien inclus dans le package."); + throw new FileNotFoundException("Le fichier podman-installer-windows-amd64.msi est introuvable. Vérifiez qu'il est bien inclus dans le package."); RunCommand("msiexec.exe", $"/i \"{msiPath}\" /qn /norestart", "Installation de Podman en cours..."); _state.PodmanInstalled = true; @@ -506,7 +506,7 @@ public partial class MainForm : Form { try { - var setupPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) ?? ".", "Resources", "studioE5-agent-setup.exe"); + var setupPath = Path.Combine(AppContext.BaseDirectory, "Resources", "studioE5-agent-setup.exe"); if (!File.Exists(setupPath)) throw new FileNotFoundException("Le fichier studioE5-agent-setup.exe est introuvable. Vérifiez qu'il est bien inclus dans le package."); @@ -600,7 +600,7 @@ public partial class MainForm : Form } // 4. Uninstall Podman - var podmanMsiPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) ?? ".", "Resources", "podman-setup.msi"); + var podmanMsiPath = Path.Combine(AppContext.BaseDirectory, "Resources", "podman-installer-windows-amd64.msi"); if (File.Exists(podmanMsiPath)) { RunCommand("msiexec.exe", $"/x \"{podmanMsiPath}\" /qn /norestart", "Désinstallation de Podman..."); diff --git a/agent/installer/setup-wizard/README.md b/agent/installer/setup-wizard/README.md index 0d19ecd..2f84b41 100644 --- a/agent/installer/setup-wizard/README.md +++ b/agent/installer/setup-wizard/README.md @@ -30,8 +30,8 @@ setup-wizard/ ├── InstallerState.cs ├── PrerequisiteChecker.cs └── Resources/ - ├── podman-setup.msi # MSI officiel Podman pour Windows - └── studioE5-agent-setup.exe # Package Inno Setup de l'agent + ├── podman-installer-windows-amd64.msi # MSI officiel Podman pour Windows + └── studioE5-agent-setup.exe # Package Inno Setup de l'agent ``` ## Build @@ -58,7 +58,7 @@ bin\Release\net8.0-windows\win-x64\publish\StudioE5-SetupWizard.exe 1. Télécharger le MSI Podman Windows : -2. Le renommer en `podman-setup.msi` et le placer dans `Resources/`. +2. Le renommer en `podman-installer-windows-amd64.msi` et le placer dans `Resources/`. 3. Générer le package Inno Setup de l’agent (`studioE5-agent-setup.exe`) et le placer dans `Resources/`. 4. Builder et publier le wizard. diff --git a/agent/installer/setup-wizard/SetupWizard.csproj b/agent/installer/setup-wizard/SetupWizard.csproj index c21bb9c..43d914f 100644 --- a/agent/installer/setup-wizard/SetupWizard.csproj +++ b/agent/installer/setup-wizard/SetupWizard.csproj @@ -11,7 +11,11 @@ - + + + + + PreserveNewest diff --git a/agent/installer/studioE5-agent.iss b/agent/installer/studioE5-agent.iss index 73e9f9c..c46802a 100644 --- a/agent/installer/studioE5-agent.iss +++ b/agent/installer/studioE5-agent.iss @@ -84,11 +84,20 @@ begin Result := Exec('podman.exe', 'machine list', '', SW_HIDE, ewWaitUntilTerminated, ResultCode) and (ResultCode = 0); end; +function GetDiskFreeSpaceEx( + lpDirectoryName: string; + var lpFreeBytesAvailableToCaller: Int64; + var lpTotalNumberOfBytes: Int64; + var lpTotalNumberOfFreeBytes: Int64 +): Boolean; +external 'GetDiskFreeSpaceExW@kernel32.dll stdcall'; + function GetFreeDiskSpaceMB(const Path: string): Cardinal; var FreeBytes, TotalBytes: Int64; + Dummy: Int64; begin - if GetDiskFreeSpaceEx(Path, FreeBytes, TotalBytes, nil) then + if GetDiskFreeSpaceEx(Path, FreeBytes, TotalBytes, Dummy) then Result := Cardinal(FreeBytes div (1024 * 1024)) else Result := 0; diff --git a/agent/studioE5-agent-setup-wizard.zip b/agent/studioE5-agent-setup-wizard.zip new file mode 100644 index 0000000..a9bf299 Binary files /dev/null and b/agent/studioE5-agent-setup-wizard.zip differ