131 lines
3.9 KiB
PowerShell
131 lines
3.9 KiB
PowerShell
# MaxSlurper Build and Package Script
|
|
# This script builds the MaxSlurper application as a standalone executable
|
|
|
|
param(
|
|
[string]$Version = "1.0.0",
|
|
[switch]$SkipBuild = $false,
|
|
[string]$Configuration = "Release"
|
|
)
|
|
|
|
$ErrorActionPreference = "Stop"
|
|
$StartTime = Get-Date
|
|
|
|
# Color output functions
|
|
function Write-Info { Write-Host $args -ForegroundColor Cyan }
|
|
function Write-Success { Write-Host $args -ForegroundColor Green }
|
|
function Write-Error { Write-Host $args -ForegroundColor Red }
|
|
function Write-Warning { Write-Host $args -ForegroundColor Yellow }
|
|
|
|
# Script variables
|
|
$ScriptRoot = $PSScriptRoot
|
|
$ProjectName = "MaxSlurper"
|
|
$ProjectDir = Join-Path $ScriptRoot $ProjectName
|
|
$ProjectFile = Join-Path $ProjectDir "$ProjectName.csproj"
|
|
$PublishDir = Join-Path $ScriptRoot "publish"
|
|
$ReleaseDir = Join-Path $ScriptRoot "release"
|
|
|
|
Write-Info "======================================"
|
|
Write-Info " MaxSlurper Build Script"
|
|
Write-Info "======================================"
|
|
Write-Info "Version: $Version"
|
|
Write-Info "Configuration: $Configuration"
|
|
Write-Info ""
|
|
|
|
# Check if project file exists
|
|
if (-not (Test-Path $ProjectFile)) {
|
|
Write-Error "Project file not found: $ProjectFile"
|
|
exit 1
|
|
}
|
|
|
|
# Clean previous builds
|
|
Write-Info "Cleaning previous builds..."
|
|
if (Test-Path $PublishDir) { Remove-Item $PublishDir -Recurse -Force }
|
|
if (Test-Path $ReleaseDir) { Remove-Item $ReleaseDir -Recurse -Force }
|
|
|
|
New-Item -ItemType Directory -Path $PublishDir -Force | Out-Null
|
|
New-Item -ItemType Directory -Path $ReleaseDir -Force | Out-Null
|
|
|
|
Write-Success "? Cleanup complete"
|
|
|
|
# Build the application
|
|
if (-not $SkipBuild) {
|
|
Write-Info ""
|
|
Write-Info "Building $ProjectName..."
|
|
|
|
# Restore dependencies
|
|
Write-Info "Restoring NuGet packages..."
|
|
dotnet restore $ProjectFile
|
|
if ($LASTEXITCODE -ne 0) {
|
|
Write-Error "Failed to restore packages"
|
|
exit 1
|
|
}
|
|
|
|
# Publish the application
|
|
Write-Info "Publishing application..."
|
|
dotnet publish $ProjectFile `
|
|
--configuration $Configuration `
|
|
--output $PublishDir `
|
|
--runtime win-x64 `
|
|
--self-contained true `
|
|
-p:PublishSingleFile=true `
|
|
-p:IncludeNativeLibrariesForSelfExtract=true `
|
|
-p:IncludeAllContentForSelfExtract=true `
|
|
-p:EnableCompressionInSingleFile=true `
|
|
-p:DebugType=embedded `
|
|
-p:Version=$Version
|
|
|
|
if ($LASTEXITCODE -ne 0) {
|
|
Write-Error "Build failed"
|
|
exit 1
|
|
}
|
|
|
|
Write-Success "? Build complete"
|
|
|
|
# Copy the executable to release folder
|
|
$ExePath = Join-Path $PublishDir "$ProjectName.exe"
|
|
if (Test-Path $ExePath) {
|
|
Copy-Item $ExePath -Destination (Join-Path $ReleaseDir "$ProjectName-$Version.exe")
|
|
Copy-Item $ExePath -Destination (Join-Path $ReleaseDir "$ProjectName.exe")
|
|
Write-Success "? Executable copied to release folder"
|
|
}
|
|
|
|
# Check if Slurp.wav was copied
|
|
$SlurpWav = Join-Path $PublishDir "Slurp.wav"
|
|
if (Test-Path $SlurpWav) {
|
|
Write-Success "? Slurp.wav included"
|
|
} else {
|
|
Write-Warning "? Slurp.wav not found - sound may not work"
|
|
}
|
|
} else {
|
|
Write-Warning "Skipping build (using existing files)"
|
|
}
|
|
|
|
# Summary
|
|
$BuildTime = (Get-Date) - $StartTime
|
|
Write-Info ""
|
|
Write-Info "======================================"
|
|
Write-Success " Build Complete!"
|
|
Write-Info "======================================"
|
|
Write-Info ""
|
|
Write-Info "Release files location: $ReleaseDir"
|
|
|
|
if (Test-Path (Join-Path $ReleaseDir "$ProjectName.exe")) {
|
|
Write-Success "? Executable: MaxSlurper.exe"
|
|
}
|
|
|
|
if (Test-Path (Join-Path $ReleaseDir "$ProjectName-$Version.exe")) {
|
|
Write-Success "? Versioned: MaxSlurper-$Version.exe"
|
|
}
|
|
|
|
Write-Info ""
|
|
Write-Info "Build time: $($BuildTime.ToString('mm\:ss'))"
|
|
Write-Info ""
|
|
|
|
# Open release folder
|
|
$OpenFolder = Read-Host "Open release folder? (Y/N)"
|
|
if ($OpenFolder -eq "Y" -or $OpenFolder -eq "y") {
|
|
Start-Process explorer.exe $ReleaseDir
|
|
}
|
|
|
|
Write-Success "Allet jut jemacht! ??"
|