Files
Prime Build 03872a39b8 fix: recover saved-rule monitoring after sleep (v1.7.9) (#96)
Renew WMI subscriptions after resume, unlock, watcher failure or prolonged silence, then rescan processes and reapply saved rules. Retry unavailable executable paths, initialize diagnostics before monitoring, and use the shared startup path. Include regression tests and v1.7.9 release metadata. Related to #95; keep open pending reporter confirmation.
2026-11-11 15:11:56 +01:00

110 lines
3.7 KiB
PowerShell

param(
[string]$Version = "1.7.9",
[string]$Configuration = "Release",
[string]$Runtime = "win-x64"
)
$ErrorActionPreference = "Stop"
function Remove-IfExists {
param([string]$Path)
if (Test-Path -LiteralPath $Path) {
Remove-Item -LiteralPath $Path -Recurse -Force
}
}
$scriptRoot = Split-Path -Parent $PSCommandPath
$projectRoot = Split-Path -Parent $scriptRoot
Set-Location -LiteralPath $projectRoot
$outputRoot = Join-Path $projectRoot ("Installer\Output\v" + $Version)
$publishDir = Join-Path $outputRoot "publish"
$portableStage = Join-Path $outputRoot "portable_stage"
$portableZip = Join-Path $outputRoot ("ThreadPilot_v" + $Version + "_Portable.zip")
$uninstallScriptPath = Join-Path $outputRoot "uninstall.bat"
$licenseSource = Join-Path $projectRoot "LICENSE"
$licenseMarkdownPath = Join-Path $outputRoot "LICENSE.md"
Write-Host "Preparing output directories..."
Remove-IfExists -Path $outputRoot
New-Item -ItemType Directory -Path $publishDir -Force | Out-Null
Write-Host "Publishing ThreadPilot $Version ($Configuration, $Runtime)..."
dotnet publish "ThreadPilot.csproj" `
--configuration $Configuration `
--runtime $Runtime `
--self-contained true `
/p:PublishSingleFile=true `
/p:EnableCompressionInSingleFile=true `
/p:DebugType=None `
/p:DebugSymbols=false `
/p:PublishTrimmed=false `
-o $publishDir
Write-Host "Creating uninstaller script..."
$uninstallerContent = @'
@echo off
setlocal EnableExtensions
title ThreadPilot Uninstaller
set "APP_DIR=%~dp0"
if "%APP_DIR:~-1%"=="\" set "APP_DIR=%APP_DIR:~0,-1%"
echo ======================================================
echo ThreadPilot Uninstaller
echo ======================================================
echo.
echo App directory: "%APP_DIR%"
echo.
echo [1/4] Closing running ThreadPilot processes...
taskkill /IM "ThreadPilot.exe" /F >nul 2>&1
echo [2/4] Removing startup task and startup registry entry...
schtasks /Delete /TN "ThreadPilot_Launch" /F >nul 2>&1
schtasks /Delete /TN "ThreadPilot_Startup" /F >nul 2>&1
reg delete "HKCU\Software\Microsoft\Windows\CurrentVersion\Run" /v "ThreadPilot" /f >nul 2>&1
echo [3/4] Removing ThreadPilot user data for this Windows account...
rem Full uninstall removes only ThreadPilot-owned per-user AppData. Normal install/update paths never run this script.
if exist "%APPDATA%\ThreadPilot" (
rd /s /q "%APPDATA%\ThreadPilot"
echo ThreadPilot user data removed.
) else (
echo No ThreadPilot user data folder found.
)
echo [4/4] Scheduling app folder removal...
start "" /min cmd /c "timeout /t 5 /nobreak >nul & rd /s /q \"%APP_DIR%\""
echo.
echo Uninstall completed. Remaining files will be removed in a few seconds.
endlocal
exit /b 0
'@
Set-Content -LiteralPath $uninstallScriptPath -Value $uninstallerContent -Encoding Ascii
if (Test-Path -LiteralPath $licenseSource) {
Copy-Item -LiteralPath $licenseSource -Destination $licenseMarkdownPath -Force
}
else {
throw "License file not found at $licenseSource"
}
Write-Host "Packaging portable archive..."
New-Item -ItemType Directory -Path $portableStage -Force | Out-Null
Copy-Item -Path (Join-Path $publishDir "*") -Destination $portableStage -Recurse -Force
Copy-Item -LiteralPath $uninstallScriptPath -Destination (Join-Path $portableStage "uninstall.bat") -Force
Copy-Item -LiteralPath $licenseMarkdownPath -Destination (Join-Path $portableStage "LICENSE.md") -Force
Remove-IfExists -Path $portableZip
Compress-Archive -Path (Join-Path $portableStage "*") -DestinationPath $portableZip -CompressionLevel Optimal
Write-Host "Cleaning staging folders..."
Remove-IfExists -Path $portableStage
Write-Host "Release packaging complete." -ForegroundColor Green
Write-Host "Portable: $portableZip"
Write-Host "Uninstall script source: $uninstallScriptPath"