1
0
mirror of https://github.com/tw93/Mole.git synced 2026-02-04 18:34:46 +00:00
Files
Mole/scripts/mole-installer.wxs
Bhadra 3bd2869e8d feat: Add Windows package manager publishing infrastructure (#343) (#356)
* feat: Add Windows package manager publishing infrastructure (#343)

- Add comprehensive release build scripts:
  - build-release.ps1: Creates portable ZIP + SHA256 checksums
  - build-exe.ps1: Standalone executable builder (PS2EXE)
  - build-msi.ps1: MSI installer builder (WiX Toolset)

- Add GitHub Actions workflow:
  - Automated builds on version tags
  - Runs tests before building
  - Auto-creates GitHub releases with artifacts

- Add package manager manifests:
  - WinGet: Complete manifests ready for microsoft/winget-pkgs
  - Chocolatey: Full package with install/uninstall scripts
  - Scoop: JSON manifest ready for submission

- Add comprehensive documentation:
  - RELEASE.md: Complete guide for building and publishing
  - Package-specific READMEs with submission instructions
  - ISSUE-343-SUMMARY.md: Quick reference and next steps

Successfully tested: Built mole-1.0.0-x64.zip (5 MB) with SHA256 checksums

Addresses #343

* chore: update contributors [skip ci]

* fix: Support uppercase V and -windows suffix in release workflow

* fix: Remove duplicate parameter definitions in clean, optimize, and purge commands

- bin/clean.ps1: Remove duplicate System, GameMedia, DebugMode, Whitelist params
- bin/optimize.ps1: Remove duplicate DebugMode param
- bin/purge.ps1: Remove duplicate DebugMode and Paths params

These duplicates were causing parser errors in tests.

* fix: Update test regex to match --dry-run format in help text

The help output shows --dry-run (kebab-case) but test was checking for DryRun (PascalCase).
Updated regex to accept both formats.

* fix: Handle Pester 5.x result object properties correctly

Pester 5.x uses different property names (Passed.Count, Failed.Count)
instead of PassedCount, FailedCount. Added fallback logic to support both formats.

* fix: Simplify Pester result parsing with better fallback logic

Since Pester already prints test results, just check for failures
and assume success if we can't parse the result object. This handles
different Pester versions more gracefully.

* feat: Add MSI and EXE builds to release workflow

- Install WiX Toolset for MSI creation
- Install PS2EXE module for standalone EXE
- Build all three formats: ZIP, MSI, EXE
- MSI and EXE builds marked optional (continue-on-error)
- Upload all artifacts to GitHub release
- Update release notes with installation instructions for all formats
- Add SHA256 verification instructions for each format

* fix: Resolve MSI and EXE build failures

MSI build fix:
- Use UTF8 without BOM for temp WXS file to avoid XML parsing errors
- WiX compiler requires clean UTF8 encoding without byte order mark

EXE build fix:
- Remove hashtable iteration that modified collection during enumeration
- Exclude null iconFile parameter from ps2exe params instead of removing it
- Prevents 'Collection was modified' exception

* fix: Properly handle encoding and version format for MSI and EXE builds

MSI fix:
- Use System.IO.File.ReadAllText/WriteAllText for consistent UTF8 without BOM
- Prevents XML parsing errors in WiX compiler

EXE fix:
- Extract numeric version only (strip '-windows' suffix) for ps2exe
- ps2exe requires version in format n.n.n.n (numeric only)
- Fallback to 1.0.0.0 if version parsing fails

* fix: Use WriteAllBytes to ensure no BOM in MSI WXS file

- Convert string to UTF8 bytes manually
- Write bytes directly to file
- This guarantees no byte order mark is added
- Prevents WiX XML parsing error at position 7

* fix: Read WXS source as bytes to completely avoid BOM issues

- Read source file as raw bytes
- Convert bytes to string using UTF8Encoding without BOM
- Replace version in string
- Convert back to bytes and write
- This completely avoids PowerShell's Get-Content BOM handling

* chore: Simplify release workflow - remove MSI build, minimal release notes

- Remove MSI build steps (has persistent BOM/encoding issues)
- Remove WiX Toolset installation
- Simplify release notes to bare minimum
- Focus on ZIP and EXE artifacts only

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2026-01-24 00:08:24 +08:00

153 lines
6.0 KiB
XML

<?xml version="1.0" encoding="UTF-8"?>
<!-- Mole Windows MSI Installer Definition -->
<!-- Build with: WiX Toolset v3/v4 -->
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<!-- Product Definition -->
<Product Id="*"
Name="Mole"
Language="1033"
Version="1.0.0"
Manufacturer="Mole Project"
UpgradeCode="12345678-1234-1234-1234-123456789ABC">
<!-- Package Information -->
<Package InstallerVersion="200"
Compressed="yes"
InstallScope="perMachine"
Description="Deep clean and optimize your Windows system"
Comments="All-in-one toolkit for Windows maintenance" />
<!-- Media Definition -->
<MediaTemplate EmbedCab="yes" />
<!-- Upgrade Logic -->
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
<!-- Installation Directory Structure -->
<Directory Id="TARGETDIR" Name="SourceDir">
<!-- Program Files -->
<Directory Id="ProgramFiles64Folder">
<Directory Id="INSTALLFOLDER" Name="Mole">
<!-- Main executable and scripts -->
<Component Id="MainExecutable" Guid="*" Win64="yes">
<File Id="MolePS1" Source="..\mole.ps1" KeyPath="yes" />
<File Id="InstallPS1" Source="..\install.ps1" />
<!-- Environment PATH modification -->
<Environment Id="PATH"
Name="PATH"
Value="[INSTALLFOLDER]"
Permanent="no"
Part="last"
Action="set"
System="yes" />
</Component>
<!-- License and documentation -->
<Component Id="Documentation" Guid="*" Win64="yes">
<File Id="LICENSE" Source="..\LICENSE" />
<File Id="README" Source="..\README.md" />
</Component>
<!-- Binary directory -->
<Directory Id="BinFolder" Name="bin">
<Component Id="BinaryFiles" Guid="*" Win64="yes">
<File Id="AnalyzeEXE" Source="..\bin\analyze.exe" />
<File Id="StatusEXE" Source="..\bin\status.exe" />
<File Id="CleanPS1" Source="..\bin\clean.ps1" />
<File Id="UninstallPS1" Source="..\bin\uninstall.ps1" />
<File Id="OptimizePS1" Source="..\bin\optimize.ps1" />
<File Id="PurgePS1" Source="..\bin\purge.ps1" />
<File Id="AnalyzePS1" Source="..\bin\analyze.ps1" />
<File Id="StatusPS1" Source="..\bin\status.ps1" />
</Component>
</Directory>
<!-- Library directory -->
<Directory Id="LibFolder" Name="lib">
<!-- Core libraries -->
<Directory Id="LibCoreFolder" Name="core">
<Component Id="CoreLibraries" Guid="*" Win64="yes">
<File Id="BasePS1" Source="..\lib\core\base.ps1" />
<File Id="CommonPS1" Source="..\lib\core\common.ps1" />
<File Id="FileOpsPS1" Source="..\lib\core\file_ops.ps1" />
<File Id="LogPS1" Source="..\lib\core\log.ps1" />
<File Id="UiPS1" Source="..\lib\core\ui.ps1" />
</Component>
</Directory>
<!-- Clean modules -->
<Directory Id="LibCleanFolder" Name="clean">
<Component Id="CleanModules" Guid="*" Win64="yes">
<File Id="AppsPS1" Source="..\lib\clean\apps.ps1" />
<File Id="CachesPS1" Source="..\lib\clean\caches.ps1" />
<File Id="DevPS1" Source="..\lib\clean\dev.ps1" />
<File Id="SystemPS1" Source="..\lib\clean\system.ps1" />
<File Id="UserPS1" Source="..\lib\clean\user.ps1" />
</Component>
</Directory>
</Directory>
</Directory>
</Directory>
<!-- Start Menu -->
<Directory Id="ProgramMenuFolder">
<Directory Id="ApplicationProgramsFolder" Name="Mole">
<Component Id="ApplicationShortcut" Guid="*">
<Shortcut Id="MoleShortcut"
Name="Mole"
Description="Windows System Maintenance Toolkit"
Target="[System64Folder]WindowsPowerShell\v1.0\powershell.exe"
Arguments="-NoProfile -ExecutionPolicy Bypass -File &quot;[INSTALLFOLDER]mole.ps1&quot;"
WorkingDirectory="INSTALLFOLDER" />
<RemoveFolder Id="CleanUpShortCut" Directory="ApplicationProgramsFolder" On="uninstall" />
<RegistryValue Root="HKCU"
Key="Software\Mole"
Name="installed"
Type="integer"
Value="1"
KeyPath="yes" />
</Component>
</Directory>
</Directory>
</Directory>
<!-- Features -->
<Feature Id="ProductFeature" Title="Mole" Level="1">
<ComponentRef Id="MainExecutable" />
<ComponentRef Id="Documentation" />
<ComponentRef Id="BinaryFiles" />
<ComponentRef Id="CoreLibraries" />
<ComponentRef Id="CleanModules" />
<ComponentRef Id="ApplicationShortcut" />
</Feature>
<!-- UI Configuration -->
<UIRef Id="WixUI_InstallDir" />
<Property Id="WIXUI_INSTALLDIR" Value="INSTALLFOLDER" />
<!-- License Agreement -->
<WixVariable Id="WixUILicenseRtf" Value="license.rtf" />
<!-- Icons -->
<!-- <Icon Id="icon.ico" SourceFile="icon.ico" /> -->
<!-- <Property Id="ARPPRODUCTICON" Value="icon.ico" /> -->
<!-- Add/Remove Programs customization -->
<Property Id="ARPURLINFOABOUT" Value="https://github.com/bhadraagada/mole" />
<Property Id="ARPCONTACT" Value="https://github.com/bhadraagada/mole/issues" />
<Property Id="ARPHELPLINK" Value="https://github.com/bhadraagada/mole" />
</Product>
</Wix>