|
| 1 | +# Test Windows Installer with UI |
| 2 | +# This creates an MSI with a basic UI |
| 3 | + |
| 4 | +Write-Host "Creating Windows Installer with UI" -ForegroundColor Cyan |
| 5 | +Write-Host "===================================" -ForegroundColor Cyan |
| 6 | + |
| 7 | +# Set environment variables |
| 8 | +$env:PROJECT_AUTH = "Digstore Contributors" |
| 9 | + |
| 10 | +# Check if we have the binary |
| 11 | +if (-not (Test-Path "target\release\digstore.exe")) { |
| 12 | + Write-Host "Building release binary..." -ForegroundColor Yellow |
| 13 | + cargo build --release |
| 14 | + if ($LASTEXITCODE -ne 0) { |
| 15 | + Write-Host "Failed to build. Please run 'cargo build --release' first." -ForegroundColor Red |
| 16 | + exit 1 |
| 17 | + } |
| 18 | +} |
| 19 | + |
| 20 | +# Check for WiX |
| 21 | +$wixPath = "C:\wix" |
| 22 | +if (-not (Test-Path "$wixPath\candle.exe")) { |
| 23 | + Write-Host "WiX not found at $wixPath" -ForegroundColor Red |
| 24 | + Write-Host "Please install WiX first or use the full test script" -ForegroundColor Red |
| 25 | + exit 1 |
| 26 | +} |
| 27 | + |
| 28 | +# Create installer directory |
| 29 | +New-Item -ItemType Directory -Force -Path "installer\windows" | Out-Null |
| 30 | + |
| 31 | +# Create WiX source file WITH UI |
| 32 | +Write-Host "Creating WiX file with UI..." -ForegroundColor Green |
| 33 | +@" |
| 34 | +<?xml version="1.0" encoding="UTF-8"?> |
| 35 | +<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"> |
| 36 | + <Product Id="*" Name="Digstore Min" Language="1033" Version="0.1.0" |
| 37 | + Manufacturer="$env:PROJECT_AUTH" UpgradeCode="A3F5C8D9-E2B1-F4A6-C9D8-E7F2A5B8C1D4"> |
| 38 | + <Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" InstallPrivileges="elevated" |
| 39 | + Description="Content-addressable storage system with Git-like semantics." /> |
| 40 | + <MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." /> |
| 41 | + <MediaTemplate EmbedCab="yes" /> |
| 42 | + |
| 43 | + <!-- Add UI Reference --> |
| 44 | + <UIRef Id="WixUI_InstallDir" /> |
| 45 | + <UIRef Id="WixUI_ErrorProgressText" /> |
| 46 | + |
| 47 | + <!-- Set the default installation directory --> |
| 48 | + <Property Id="WIXUI_INSTALLDIR" Value="INSTALLFOLDER" /> |
| 49 | + |
| 50 | + <!-- License file (optional - we'll skip it for now) --> |
| 51 | + <WixVariable Id="WixUILicenseRtf" Value="installer\windows\license.rtf" Overridable="yes" /> |
| 52 | + |
| 53 | + <!-- Custom dialog text --> |
| 54 | + <Property Id="WIXUI_EXITDIALOGOPTIONALTEXT" Value="Digstore has been successfully installed. Please restart your terminal or log out and back in for PATH changes to take effect." /> |
| 55 | + |
| 56 | + <Feature Id="ProductFeature" Title="Digstore Min" Level="1" Display="expand" ConfigurableDirectory="INSTALLFOLDER"> |
| 57 | + <ComponentGroupRef Id="ProductComponents" /> |
| 58 | + <ComponentRef Id="Path" /> |
| 59 | + <ComponentRef Id="ProgramMenuDir" /> |
| 60 | + </Feature> |
| 61 | + |
| 62 | + <Directory Id="TARGETDIR" Name="SourceDir"> |
| 63 | + <Directory Id="ProgramFilesFolder"> |
| 64 | + <Directory Id="INSTALLFOLDER" Name="Digstore" /> |
| 65 | + </Directory> |
| 66 | + <Directory Id="ProgramMenuFolder" Name="Programs"> |
| 67 | + <Directory Id="ProgramMenuDir" Name="Digstore Min" /> |
| 68 | + </Directory> |
| 69 | + </Directory> |
| 70 | + |
| 71 | + <ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER"> |
| 72 | + <Component Id="MainExecutable"> |
| 73 | + <File Id="digstore.exe" Source="..\..\target\release\digstore.exe" KeyPath="yes"> |
| 74 | + <Shortcut Id="startmenuDigstore" Directory="ProgramMenuDir" Name="Digstore Min" |
| 75 | + WorkingDirectory="INSTALLFOLDER" Icon="digstore.exe" IconIndex="0" Advertise="yes" /> |
| 76 | + </File> |
| 77 | + </Component> |
| 78 | + </ComponentGroup> |
| 79 | + |
| 80 | + <DirectoryRef Id="TARGETDIR"> |
| 81 | + <Component Id="Path" Guid="B3F5C8D9-E2B1-F4A6-C9D8-E7F2A5B8C1D5"> |
| 82 | + <Environment Id="UpdatePath" Name="PATH" Value="[INSTALLFOLDER]" Permanent="no" Part="last" Action="set" System="yes" /> |
| 83 | + <RegistryValue Root="HKCU" Key="Software\[Manufacturer]\[ProductName]" Name="PathComponent" Type="integer" Value="1" KeyPath="yes" /> |
| 84 | + </Component> |
| 85 | + </DirectoryRef> |
| 86 | + |
| 87 | + <Component Id="ProgramMenuDir" Guid="C3F5C8D9-E2B1-F4A6-C9D8-E7F2A5B8C1D6" Directory="ProgramMenuDir"> |
| 88 | + <RemoveFolder Id="ProgramMenuDir" On="uninstall" /> |
| 89 | + <RegistryValue Root="HKCU" Key="Software\[Manufacturer]\[ProductName]" Type="string" Value="" KeyPath="yes" /> |
| 90 | + </Component> |
| 91 | + |
| 92 | + <Icon Id="digstore.exe" SourceFile="..\..\target\release\digstore.exe" /> |
| 93 | + |
| 94 | + <!-- Show success message --> |
| 95 | + <CustomAction Id="ShowSuccessMessage" Script="vbscript"> |
| 96 | + <![CDATA[ |
| 97 | + MsgBox "Digstore has been installed successfully!" & vbCrLf & vbCrLf & _ |
| 98 | + "Installation location: " & Session.Property("INSTALLFOLDER") & vbCrLf & vbCrLf & _ |
| 99 | + "Please restart your terminal to use 'digstore' from the command line.", _ |
| 100 | + vbInformation, "Installation Complete" |
| 101 | + ]]> |
| 102 | + </CustomAction> |
| 103 | + |
| 104 | + <!-- Uncomment to show message after install --> |
| 105 | + <!-- <InstallExecuteSequence> |
| 106 | + <Custom Action="ShowSuccessMessage" After="InstallFinalize">NOT Installed</Custom> |
| 107 | + </InstallExecuteSequence> --> |
| 108 | + </Product> |
| 109 | +</Wix> |
| 110 | +"@ | Out-File -FilePath installer\windows\digstore-ui.wxs -Encoding utf8 |
| 111 | + |
| 112 | +# Create a simple license file |
| 113 | +@" |
| 114 | +Digstore Min - Content-addressable storage system |
| 115 | +
|
| 116 | +Copyright (c) 2024 Digstore Contributors |
| 117 | +
|
| 118 | +Permission is hereby granted, free of charge, to any person obtaining a copy |
| 119 | +of this software and associated documentation files (the "Software"), to deal |
| 120 | +in the Software without restriction. |
| 121 | +
|
| 122 | +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND. |
| 123 | +"@ | Out-File -FilePath installer\windows\license.rtf -Encoding utf8 |
| 124 | + |
| 125 | +Write-Host "Compiling installer..." -ForegroundColor Yellow |
| 126 | +Push-Location installer\windows |
| 127 | +try { |
| 128 | + # Compile with UI extensions |
| 129 | + & "$wixPath\candle.exe" -ext WixUIExtension digstore-ui.wxs |
| 130 | + if ($LASTEXITCODE -ne 0) { |
| 131 | + Write-Host "Candle compilation failed" -ForegroundColor Red |
| 132 | + exit 1 |
| 133 | + } |
| 134 | + |
| 135 | + Write-Host "Linking installer..." -ForegroundColor Yellow |
| 136 | + & "$wixPath\light.exe" -ext WixUIExtension digstore-ui.wixobj -o digstore-windows-x64-ui.msi |
| 137 | + if ($LASTEXITCODE -ne 0) { |
| 138 | + Write-Host "Light linking failed" -ForegroundColor Red |
| 139 | + exit 1 |
| 140 | + } |
| 141 | + |
| 142 | + Write-Host "`nSuccess! Installer with UI created at:" -ForegroundColor Green |
| 143 | + Write-Host (Resolve-Path "digstore-windows-x64-ui.msi").Path -ForegroundColor Cyan |
| 144 | + |
| 145 | + Write-Host "`nTo test the installer:" -ForegroundColor Yellow |
| 146 | + Write-Host "msiexec /i installer\windows\digstore-windows-x64-ui.msi" -ForegroundColor White |
| 147 | + |
| 148 | +} finally { |
| 149 | + Pop-Location |
| 150 | +} |
| 151 | + |
| 152 | +Write-Host "`nNote: The installer will show:" -ForegroundColor Cyan |
| 153 | +Write-Host "- Welcome screen" -ForegroundColor White |
| 154 | +Write-Host "- Installation directory selection" -ForegroundColor White |
| 155 | +Write-Host "- Progress bar during installation" -ForegroundColor White |
| 156 | +Write-Host "- Completion screen" -ForegroundColor White |
0 commit comments