cu-trainer/Ultra Paradise Linux/plugin/build.ps1
| 1 | param([string]$GameDir = "C:\Program Files (x86)\Steam\steamapps\common\Casualties Unknown") |
| 2 | $ErrorActionPreference = "Stop" |
| 3 | $root = $PSScriptRoot |
| 4 | $game = $GameDir |
| 5 | $M = Join-Path $game "CasualtiesUnknown_Data\Managed" |
| 6 | $C = Join-Path $game "BepInEx\core" |
| 7 | $win = Join-Path $root "..\..\Ultra Paradise Application\src" |
| 8 | $csc = "C:\Windows\Microsoft.NET\Framework64\v4.0.30319\csc.exe" |
| 9 | $outDir = Join-Path $root "bin" |
| 10 | New-Item -ItemType Directory -Force $outDir | Out-Null |
| 11 | $out = Join-Path $outDir "UltraParadise.CUTrainer.dll" |
| 12 | |
| 13 | $refs = @() |
| 14 | foreach ($n in @("mscorlib","System","System.Core","netstandard","UnityEngine","UnityEngine.CoreModule","UnityEngine.Physics2DModule","UnityEngine.InputLegacyModule","UnityEngine.AudioModule","UnityEngine.UnityWebRequestModule","UnityEngine.UnityWebRequestAudioModule","UnityEngine.UI","UnityEngine.UIModule","UnityEngine.IMGUIModule","UnityEngine.ImageConversionModule","UnityEngine.TextRenderingModule","Unity.TextMeshPro","Assembly-CSharp")) { |
| 15 | $p = Join-Path $M "$n.dll" |
| 16 | if (-not (Test-Path $p)) { throw "missing $p" } |
| 17 | $refs += "/r:`"$p`"" |
| 18 | } |
| 19 | $lib = (Resolve-Path (Join-Path $root "..\..\Ultra Paradise Application\lib")).Path |
| 20 | $refs += "/r:`"$(Join-Path $lib '0Harmony.dll')`"" |
| 21 | foreach ($n in @("0Harmony","MonoMod.RuntimeDetour","MonoMod.Utils","Mono.Cecil")) { |
| 22 | $p = Join-Path $lib "$n.dll" |
| 23 | if (-not (Test-Path $p)) { throw "missing $p" } |
| 24 | $refs += "/resource:`"$p`",lib.$n.dll" |
| 25 | } |
| 26 | $srcs = @((Join-Path $win "Payload.cs"), (Join-Path $win "Engine.cs"), (Join-Path $win "Health.cs"), (Join-Path $win "Debug.cs"),(Join-Path $win "MyMods.cs"),(Join-Path $win "Music.cs"),(Join-Path $root "..\shared\Cheats.cs"), (Join-Path $root "LinuxHost.cs")) | % { "`"$((Resolve-Path $_).Path)`"" } |
| 27 | $a = @("/nologo","/nostdlib+","/noconfig","/target:library","/langversion:5","/optimize+","/define:LINUXPLUGIN","/nowarn:162","/out:`"$out`"") + $refs + $srcs |
| 28 | & $csc $a |
| 29 | if ($LASTEXITCODE -ne 0) { throw "plugin build failed" } |
| 30 | Write-Host ("plugin {0} bytes" -f (Get-Item $out).Length) |