|
| 1 | +# 🛠️ Click Guardian — MSI Installer Guide |
| 2 | + |
| 3 | +This guide shows how to create a **Windows MSI installer** for your `click-guardian.exe` using `go-msi`. This includes setting shortcuts, upgrade logic, and system integration. |
| 4 | + |
| 5 | +--- |
| 6 | + |
| 7 | +## 📁 Project Structure |
| 8 | + |
| 9 | +``` |
| 10 | +click-guardian-installer/ |
| 11 | +├── dist/ |
| 12 | +│ └── click-guardian.exe # Compiled executable |
| 13 | +├── assets/ |
| 14 | +│ └── icon.ico # Optional icon for shortcuts |
| 15 | +├── wix.json # MSI configuration |
| 16 | +``` |
| 17 | + |
| 18 | +--- |
| 19 | + |
| 20 | +## 🔧 Prerequisites |
| 21 | + |
| 22 | +- ✅ Go installed and in `PATH` |
| 23 | +- ✅ Windows machine |
| 24 | +- ✅ **WiX Toolset** installed: |
| 25 | + ```bash |
| 26 | + # Option 1: Download from official site |
| 27 | + # https://wixtoolset.org/releases/ |
| 28 | + |
| 29 | + # Option 2: Using Chocolatey |
| 30 | + choco install wixtoolset |
| 31 | + |
| 32 | + # Option 3: Using winget |
| 33 | + winget install WiXToolset.WiXToolset |
| 34 | + ``` |
| 35 | + > ⚠️ **Important**: After installation, restart your terminal/command prompt to ensure WiX tools (`candle.exe` and `light.exe`) are in your PATH. |
| 36 | +
|
| 37 | +- ✅ `go-msi` installed: |
| 38 | + ```bash |
| 39 | + go install github.com/mh-cbon/go-msi@latest |
| 40 | + ``` |
| 41 | + |
| 42 | +--- |
| 43 | + |
| 44 | +## 📄 Step 1: Create `wix.json` |
| 45 | + |
| 46 | +Create `wix.json` in the root of your installer folder: |
| 47 | + |
| 48 | +```json |
| 49 | +{ |
| 50 | + "product": "Click Guardian", |
| 51 | + "company": "Click Guardian Project", |
| 52 | + "version": "1.0.1", |
| 53 | + "license": "GPL-3.0", |
| 54 | + "upgrade-code": "d900466f-5e04-43c5-b7f4-cbeb7ce26bce", |
| 55 | + "product-code": "d900466f-5e04-43c5-b7f4-cbeb7ce26rce", |
| 56 | + "base": "dist", |
| 57 | + "items": ["click-guardian.exe"], |
| 58 | + "files": { |
| 59 | + "guid": "ea91758f-b81c-4384-8bbc-ddb21be99e96", |
| 60 | + "items": ["click-guardian.exe"] |
| 61 | + }, |
| 62 | + "env": { |
| 63 | + "guid": "9779be66-6aea-41d9-a1e5-6657cdb98ea0", |
| 64 | + "vars": [] |
| 65 | + }, |
| 66 | + "shortcuts": { |
| 67 | + "guid": "8a69c043-2d46-4604-954c-648f667b2233", |
| 68 | + "items": [ |
| 69 | + { |
| 70 | + "name": "Click Guardian", |
| 71 | + "description": "Click Guardian - Double-Click Protection", |
| 72 | + "target": "[INSTALLDIR]\\click-guardian.exe", |
| 73 | + "wdir": "DesktopFolder", |
| 74 | + "arguments": "", |
| 75 | + "icon": "../assets/icon.ico" |
| 76 | + }, |
| 77 | + { |
| 78 | + "name": "Click Guardian", |
| 79 | + "description": "Click Guardian - Double-Click Protection", |
| 80 | + "target": "[INSTALLDIR]\\click-guardian.exe", |
| 81 | + "wdir": "ProgramMenuFolder", |
| 82 | + "arguments": "", |
| 83 | + "icon": "../assets/icon.ico" |
| 84 | + } |
| 85 | + ] |
| 86 | + }, |
| 87 | + "choco": {} |
| 88 | +} |
| 89 | +``` |
| 90 | + |
| 91 | +> 🔐 Generate GUIDs with: |
| 92 | +
|
| 93 | +```bash |
| 94 | +go-msi set-guid |
| 95 | +``` |
| 96 | + |
| 97 | +or use online tool like this: [https://www.guidgenerator.com/](https://www.guidgenerator.com/) |
| 98 | + |
| 99 | +--- |
| 100 | + |
| 101 | +## 🏢 Step 2: Build the Installer |
| 102 | + |
| 103 | +### Option 1: Automated Build (Recommended) |
| 104 | + |
| 105 | +Use the automated release build script: |
| 106 | + |
| 107 | +```bash |
| 108 | +scripts\release-build.bat |
| 109 | +``` |
| 110 | + |
| 111 | +This will: |
| 112 | +- ⚙️ Build the executable |
| 113 | +- 📎 Create portable ZIP package |
| 114 | +- 🔄 Copy icon from `assets/` folder |
| 115 | +- 📦 Generate MSI installer with shortcuts |
| 116 | +- 🧽 Clean up temporary files |
| 117 | +- 📁 List all created distribution files |
| 118 | + |
| 119 | +### Option 2: Manual Build |
| 120 | + |
| 121 | +From the project root, run: |
| 122 | + |
| 123 | +```bash |
| 124 | +# Copy icon from assets (required for WiX) |
| 125 | +copy assets\icon.ico icon.ico |
| 126 | + |
| 127 | +# Build MSI installer |
| 128 | +go-msi make --msi dist/click-guardian-installer.msi --version 1.0.1 --src templates |
| 129 | + |
| 130 | +# Clean up |
| 131 | +del icon.ico |
| 132 | +``` |
| 133 | + |
| 134 | +### What gets created: |
| 135 | + |
| 136 | +- 💻 **click-guardian.exe** - Standalone executable |
| 137 | +- 📎 **click-guardian-v1.0.1-windows-portable.zip** - Portable package |
| 138 | +- 📦 **click-guardian-installer.msi** - Windows installer with: |
| 139 | + - Desktop + Start Menu shortcuts |
| 140 | + - Add/Remove Programs entry |
| 141 | + - Start Menu search visibility |
| 142 | + - Custom icon from assets folder |
| 143 | + |
| 144 | +--- |
| 145 | + |
| 146 | +## 🔁 Future Updates |
| 147 | + |
| 148 | +To update the app: |
| 149 | + |
| 150 | +- 🔁 Keep the same `upgrade-code` |
| 151 | +- 🆕 Change the `product-code` |
| 152 | +- ⬆️ Bump `version` |
| 153 | +- ✅ Rebuild `.msi` |
| 154 | + |
| 155 | +Windows will automatically remove the previous version and install the new one. |
| 156 | + |
| 157 | +--- |
| 158 | + |
| 159 | +## 🐛 Troubleshooting |
| 160 | + |
| 161 | +### WiX Tools Not Found |
| 162 | +``` |
| 163 | +CreateFile C:\Users\...\go\bin\templates: The system cannot find the file specified. |
| 164 | +``` |
| 165 | +**Solution**: Install WiX Toolset and restart your terminal. |
| 166 | + |
| 167 | +### Icon File Not Found |
| 168 | +``` |
| 169 | +LGHT0103: The system cannot find the file 'icon.ico'. |
| 170 | +``` |
| 171 | +**Solution**: Ensure `assets/icon.ico` exists and the build script copies it correctly. |
| 172 | + |
| 173 | +### Relative Path Errors |
| 174 | +``` |
| 175 | +Rel: can't make K:\...\file.exe relative to C:\...\temp |
| 176 | +``` |
| 177 | +**Solution**: This usually occurs with cross-drive paths. The automated build script handles this by using proper temp directory management. |
| 178 | + |
| 179 | +### MSI Build Fails |
| 180 | +**Check**: |
| 181 | +1. ✅ WiX Toolset installed (`candle.exe` and `light.exe` in PATH) |
| 182 | +2. ✅ `go-msi` installed (`go-msi --version` works) |
| 183 | +3. ✅ `templates/main.wxs` exists |
| 184 | +4. ✅ `wix.json` syntax is valid |
| 185 | +5. ✅ Icon file exists in assets folder |
| 186 | + |
| 187 | +--- |
| 188 | + |
| 189 | +## ✅ Bonus Tips |
| 190 | + |
| 191 | +- Add autostart, custom install paths, registry entries, or tray options by extending `wix.json`. |
| 192 | +- For more customization, explore [`WiX Toolset`](https://wixtoolset.org/). |
| 193 | +- Use `scripts\release-build.bat` for one-command building of all distribution formats. |
| 194 | + |
| 195 | +--- |
| 196 | + |
| 197 | +Made with 💡 by Azizul (and Copilot 😄) |
0 commit comments