# steamAPI Build Script # Package steamAPI project into a standalone Windows x64 executable param( [switch]$Debug, [switch]$Clean, [switch]$Help ) $ErrorActionPreference = "Stop" $SteamAPIPath = $PSScriptRoot $OutputDir = Join-Path $SteamAPIPath "publish" $ProjectFile = Join-Path $SteamAPIPath "steamAPI.csproj" function Write-ColorOutput { param( [string]$Message, [string]$Color = "White" ) $colors = @{ "Red" = [ConsoleColor]::Red "Green" = [ConsoleColor]::Green "Yellow" = [ConsoleColor]::Yellow "Cyan" = [ConsoleColor]::Cyan "White" = [ConsoleColor]::White } Write-Host $Message -ForegroundColor $colors[$Color] } function Show-Help { Write-Host "" Write-Host "steamAPI Build Script" Write-Host "Usage: .\build.ps1 [options]" Write-Host "" Write-Host "Options:" Write-Host " -Debug Use Debug configuration (default: Release)" Write-Host " -Clean Clean output directory before building" Write-Host " -Help Show this help message" Write-Host "" Write-Host "Examples:" Write-Host " .\build.ps1 # Release build" Write-Host " .\build.ps1 -Debug # Debug build" Write-Host " .\build.ps1 -Clean # Clean and build" Write-Host "" } if ($Help) { Show-Help exit 0 } Write-ColorOutput "======================================" "Cyan" Write-ColorOutput " steamAPI Build Script" "Cyan" Write-ColorOutput "======================================" "Cyan" Write-Host "" if (-not (Test-Path $ProjectFile)) { Write-ColorOutput "Error: Project file not found: $ProjectFile" "Red" exit 1 } Write-ColorOutput "[1/4] Restoring NuGet packages..." "Yellow" Push-Location $SteamAPIPath try { dotnet restore $ProjectFile if ($LASTEXITCODE -ne 0) { throw "dotnet restore failed" } Write-ColorOutput " NuGet packages restored successfully" "Green" } finally { Pop-Location } if ($Clean) { Write-ColorOutput "[2/4] Cleaning output directory..." "Yellow" if (Test-Path $OutputDir) { Remove-Item -Path $OutputDir -Recurse -Force Write-ColorOutput " Clean completed" "Green" } else { Write-ColorOutput " Output directory does not exist, skipping" "Green" } } else { Write-ColorOutput "[2/4] Skipping clean (use -Clean to clean)" "Yellow" } $Configuration = if ($Debug) { "Debug" } else { "Release" } Write-ColorOutput "[3/4] Building and publishing ($Configuration)..." "Yellow" Push-Location $SteamAPIPath try { $publishArgs = @( "publish", $ProjectFile, "-c", $Configuration, "-r", "win-x64", "--self-contained", "true", "-p:PublishSingleFile=true", "-p:PublishReadyToRun=true", "-p:IncludeNativeLibrariesForSelfExtract=true", "-o", $OutputDir ) dotnet @publishArgs if ($LASTEXITCODE -ne 0) { throw "dotnet publish failed" } Write-ColorOutput " Publish completed" "Green" } finally { Pop-Location } Write-ColorOutput "[4/4] Build result:" "Yellow" Write-Host "" $exePath = Join-Path $OutputDir "steamAPI.exe" if (Test-Path $exePath) { $fileInfo = Get-Item $exePath $sizeMB = [math]::Round($fileInfo.Length / 1MB, 2) Write-ColorOutput " Executable: $exePath" "Green" Write-ColorOutput " File size: $sizeMB MB" "Green" Write-ColorOutput " Output directory: $OutputDir" "Green" Write-Host "" Write-ColorOutput " Output files:" "Cyan" Get-ChildItem $OutputDir | ForEach-Object { $itemSize = if ($_.PSIsContainer) { "