-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild-release.ps1
More file actions
113 lines (93 loc) Β· 3.73 KB
/
Copy pathbuild-release.ps1
File metadata and controls
113 lines (93 loc) Β· 3.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
param(
[string]$Version = "1.3.0",
[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_Startup" /F >nul 2>&1
reg delete "HKCU\Software\Microsoft\Windows\CurrentVersion\Run" /v "ThreadPilot" /f >nul 2>&1
echo [3/4] Optional user data cleanup...
set "REMOVE_DATA=N"
set /p REMOVE_DATA=Do you want to remove user settings at "%APPDATA%\ThreadPilot"? [y/N]:
if /I "%REMOVE_DATA%"=="Y" (
if exist "%APPDATA%\ThreadPilot" (
rd /s /q "%APPDATA%\ThreadPilot"
echo User settings removed.
) else (
echo No user settings folder found.
)
) else (
echo User settings were kept.
)
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"