save-anywhere/build.ps1
| 1 | param([string]$GameDir = "C:\Program Files (x86)\Steam\steamapps\common\Casualties Unknown") |
| 2 | $ErrorActionPreference = "Stop" |
| 3 | $root = $PSScriptRoot |
| 4 | $M = Join-Path $GameDir "CasualtiesUnknown_Data\Managed" |
| 5 | $C = Join-Path $GameDir "BepInEx\core" |
| 6 | $src = Join-Path $root "SaveAnywhere.cs" |
| 7 | $out = Join-Path $root "SaveAnywhere.dll" |
| 8 | $csc = "C:\Windows\Microsoft.NET\Framework64\v4.0.30319\csc.exe" |
| 9 | |
| 10 | $names = @( |
| 11 | "mscorlib","System","System.Core","netstandard", |
| 12 | "UnityEngine","UnityEngine.CoreModule","UnityEngine.UI","UnityEngine.UIModule", |
| 13 | "UnityEngine.InputLegacyModule","UnityEngine.TextRenderingModule","UnityEngine.AudioModule", |
| 14 | "UnityEngine.ImageConversionModule","UnityEngine.IMGUIModule","UnityEngine.Physics2DModule", |
| 15 | "UnityEngine.TilemapModule","UnityEngine.GridModule","Unity.TextMeshPro", |
| 16 | "Unity.RenderPipelines.Universal.Runtime","Unity.RenderPipelines.Core.Runtime", |
| 17 | "UnityEngine.UnityWebRequestModule","Assembly-CSharp" |
| 18 | ) |
| 19 | $refs = @() |
| 20 | foreach ($n in $names) { |
| 21 | $p = Join-Path $M "$n.dll" |
| 22 | if (-not (Test-Path $p)) { throw "missing $p" } |
| 23 | $refs += "/r:`"$p`"" |
| 24 | } |
| 25 | foreach ($n in @("BepInEx","0Harmony","Newtonsoft.Json")) { |
| 26 | $p = Join-Path $C "$n.dll" |
| 27 | if (-not (Test-Path $p)) { $p = Join-Path $M "$n.dll" } |
| 28 | if (-not (Test-Path $p)) { throw "missing $n.dll (install BepInEx 5 first)" } |
| 29 | $refs += "/r:`"$p`"" |
| 30 | } |
| 31 | $extra = @() |
| 32 | $logo = Join-Path $root "art\cloudflare.png" |
| 33 | if (Test-Path $logo) { $extra += "/resource:`"$logo`",SaveAnywhere.cloudflare.png" } |
| 34 | |
| 35 | $a = @("/nologo","/nostdlib+","/noconfig","/target:library","/langversion:5","/optimize+","/out:`"$out`"") + $refs + $extra + @("`"$src`"") |
| 36 | & $csc $a |
| 37 | if ($LASTEXITCODE -ne 0) { throw "build failed" } |
| 38 | Write-Host ("SaveAnywhere.dll {0} bytes" -f (Get-Item $out).Length) |