|
| 1 | +$ErrorActionPreference = "Stop" |
| 2 | + |
| 3 | +$distBase = "dist" |
| 4 | +$distDir = "$distBase\win-x64" |
| 5 | + |
| 6 | +# Ensure output directory exists and is clean |
| 7 | +if (Test-Path $distBase) { |
| 8 | + Remove-Item $distBase -Recurse -Force |
| 9 | +} |
| 10 | +New-Item -ItemType Directory -Path $distDir | Out-Null |
| 11 | + |
| 12 | +Write-Host "Copying core files from bin directory..." -ForegroundColor Cyan |
| 13 | + |
| 14 | +# We need to merge files from bin (managed dlls) and bin\win-x64 (runtime and exe) |
| 15 | +# 1. Copy the win-x64 runtime/exe files first |
| 16 | +$binWin64 = "bin\win-x64" |
| 17 | +if (Test-Path $binWin64) { |
| 18 | + Copy-Item "$binWin64\*" -Destination $distDir -Recurse -Force |
| 19 | +} else { |
| 20 | + Write-Warning "bin\win-x64 not found. The game might not launch." |
| 21 | +} |
| 22 | + |
| 23 | +# 2. Copy the managed DLLs from bin root, avoiding the nested win-x64 folder |
| 24 | +# This fixes the missing OpenRA.Mods.Cnc.dll issue |
| 25 | +$binRoot = "bin" |
| 26 | +if (Test-Path $binRoot) { |
| 27 | + Get-ChildItem -Path $binRoot -File | ForEach-Object { |
| 28 | + Copy-Item $_.FullName -Destination $distDir -Force |
| 29 | + } |
| 30 | +} |
| 31 | + |
| 32 | +# 2. Copy Game Assets (Mods and Shaders) |
| 33 | +# These are usually in the root, not inside bin |
| 34 | +Write-Host "Copying assets (mods, glsl)..." -ForegroundColor Cyan |
| 35 | +$modsDest = "$distDir\mods" |
| 36 | +$glslDest = "$distDir\glsl" |
| 37 | + |
| 38 | +if (-not (Test-Path $modsDest)) { New-Item -ItemType Directory -Path $modsDest | Out-Null } |
| 39 | +if (-not (Test-Path $glslDest)) { New-Item -ItemType Directory -Path $glslDest | Out-Null } |
| 40 | + |
| 41 | +# Copy all mods |
| 42 | +if (Test-Path "mods") { |
| 43 | + Copy-Item "mods\*" -Destination $modsDest -Recurse |
| 44 | +} else { |
| 45 | + Write-Warning "Directory 'mods' not found in root." |
| 46 | +} |
| 47 | + |
| 48 | +# Copy shaders |
| 49 | +if (Test-Path "glsl") { |
| 50 | + Copy-Item "glsl\*" -Destination $glslDest -Recurse |
| 51 | +} else { |
| 52 | + Write-Warning "Directory 'glsl' not found in root." |
| 53 | +} |
| 54 | + |
| 55 | +# 3. Copy Documentation |
| 56 | +Write-Host "Copying licenses and docs..." -ForegroundColor Cyan |
| 57 | +Copy-Item "AUTHORS", "COPYING", "socket-apis.md", "VERSION", "global mix database.dat" -Destination $distDir -ErrorAction SilentlyContinue |
| 58 | + |
| 59 | +# 4. Create Launch Scripts |
| 60 | +Write-Host "Creating launcher scripts..." -ForegroundColor Cyan |
| 61 | + |
| 62 | +# Launch OpenRA (Generic) - similar to user's reference |
| 63 | +$genericLauncher = @" |
| 64 | +@echo off |
| 65 | +setlocal ENABLEDELAYEDEXPANSION |
| 66 | +
|
| 67 | +set "BASE=%~dp0win-x64" |
| 68 | +cd /d "%BASE%" |
| 69 | +
|
| 70 | +set "MODARG=Game.Mod=copilot" |
| 71 | +if exist "%CD%\mods\copilot\mod.yaml" ( |
| 72 | + set "MODARG=Game.Mod=%CD%\mods\copilot" |
| 73 | +) |
| 74 | +
|
| 75 | +start "" "OpenRA.exe" %MODARG% %* |
| 76 | +endlocal |
| 77 | +"@ |
| 78 | +Set-Content -Path "$distBase\launch-openra.cmd" -Value $genericLauncher |
| 79 | + |
| 80 | +Write-Host "------------------------------------------------------" -ForegroundColor Green |
| 81 | +Write-Host "Build Complete (Copy Mode)!" -ForegroundColor Green |
| 82 | +Write-Host "Location: $distBase" -ForegroundColor Green |
| 83 | +Write-Host "Action: Run 'launch-openra.cmd' to play." -ForegroundColor Green |
| 84 | +Write-Host "------------------------------------------------------" -ForegroundColor Green |
0 commit comments