cu-trainer/Ultra Paradise Linux/build.ps1
| 1 | $ErrorActionPreference = "Stop" |
| 2 | $root = $PSScriptRoot |
| 3 | $ver = ([xml](Get-Content (Join-Path $root "app\UltraParadise.Linux.csproj"))).Project.PropertyGroup[0].Version |
| 4 | $env:DOTNET_CLI_TELEMETRY_OPTOUT = "1"; $env:DOTNET_NOLOGO = "1" |
| 5 | |
| 6 | Push-Location (Join-Path $root "app") |
| 7 | try { |
| 8 | & dotnet publish -c Release -r linux-x64 -o (Join-Path $root "out\linux-x64") | Out-Null |
| 9 | if ($LASTEXITCODE -ne 0) { throw "app build failed" } |
| 10 | } finally { Pop-Location } |
| 11 | |
| 12 | $stage = Join-Path $root "out\pkg\UltraParadise-CU-Trainer" |
| 13 | Remove-Item (Join-Path $root "out\pkg") -Recurse -Force -ErrorAction SilentlyContinue |
| 14 | New-Item -ItemType Directory $stage | Out-Null |
| 15 | Copy-Item (Join-Path $root "out\linux-x64\UltraParadiseCUTrainer") $stage |
| 16 | Copy-Item (Join-Path $root "art\icon.png") $stage |
| 17 | $readme = [IO.File]::ReadAllText((Join-Path $root "README.txt")).Replace("@@VER@@", $ver).Replace("`r`n", "`n") |
| 18 | [IO.File]::WriteAllText((Join-Path $stage "README.txt"), $readme, (New-Object Text.UTF8Encoding($false))) |
| 19 | |
| 20 | Get-ChildItem $root -Filter "UltraParadise-Linux-*" | Remove-Item -Force |
| 21 | $tgz = Join-Path $root "UltraParadise-Linux-$ver.tar.gz" |
| 22 | $b = ($root -replace '\\', '/') -replace '^([A-Za-z]):', '/$1' |
| 23 | & "C:\Program Files\Git\bin\bash.exe" -lc "cd '$b/out/pkg' && tar --owner=0 --group=0 --numeric-owner --mode=755 -czf '$b/UltraParadise-Linux-$ver.tar.gz' UltraParadise-CU-Trainer" |
| 24 | $zip = Join-Path $root "UltraParadise-Linux-$ver.zip" |
| 25 | & powershell -ExecutionPolicy Bypass -File (Join-Path $root "zipunix.ps1") -Src $stage -Out $zip -Exec UltraParadiseCUTrainer |
| 26 | |
| 27 | Write-Host "" |
| 28 | Write-Host "Linux v$ver" |
| 29 | Write-Host (" {0} {1:N1} MB {2}" -f (Split-Path $tgz -Leaf), ((Get-Item $tgz).Length / 1MB), (Get-FileHash $tgz).Hash.ToLower()) |
| 30 | Write-Host (" {0} {1:N1} MB {2}" -f (Split-Path $zip -Leaf), ((Get-Item $zip).Length / 1MB), (Get-FileHash $zip).Hash.ToLower()) |