Files
oniagent/scripts/build_mod.sh
root bff8aea846 build: fix csproj (remove NuGet deps, add 0Harmony ref) + improved build script
csproj: removed Lib.Harmony and System.Text.Json NuGet packages (game bundles these),
added 0Harmony.dll reference from game directory, LangVersion=latest
build_mod.sh: auto-detect Managed/ subdirectory, support Linux/macOS/Windows paths,
better error messages, install instructions

C# code verification: 0 syntax errors, 8 missing-reference-only errors (expected)
2026-05-22 10:45:40 +08:00

62 lines
2.1 KiB
Bash
Executable File

#!/usr/bin/env bash
# Build the ONI Agent Bridge Mod
# Requires: mono-complete (for mcs compiler)
# Requires: ONI game installed to get reference DLLs
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
PROJECT_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"
MOD_DIR="$PROJECT_DIR/mod"
OUTPUT_DIR="$MOD_DIR/bin"
ONI_PATH="${ONI_PATH:-}"
if [ -z "$ONI_PATH" ]; then
for candidate in \
"$HOME/.steam/steam/steamapps/common/OxygenNotIncluded" \
"$HOME/.local/share/Steam/steamapps/common/OxygenNotIncluded" \
"/c/Program Files (x86)/Steam/steamapps/common/OxygenNotIncluded" \
"/mnt/c/Program Files (x86)/Steam/steamapps/common/OxygenNotIncluded"; do
MANAGED="$candidate/OxygenNotIncluded_Data/Managed"
if [ -d "$MANAGED" ]; then
ONI_PATH="$MANAGED"
break
fi
done
fi
if [ -z "$ONI_PATH" ]; then
echo "[!] ONI installation not found."
echo " Set ONI_PATH to the Managed directory:"
echo ' export ONI_PATH="/path/to/OxygenNotIncluded_Data/Managed"'
exit 1
fi
echo "[Build] ONI: $ONI_PATH"
for dll in "$ONI_PATH/Assembly-CSharp.dll" "$ONI_PATH/UnityEngine.dll" \
"$ONI_PATH/UnityEngine.CoreModule.dll" "$ONI_PATH/0Harmony.dll"; do
if [ ! -f "$dll" ]; then echo "[!] Missing: $dll"; exit 1; fi
done
mkdir -p "$OUTPUT_DIR"
REFS=""
for dll in "$ONI_PATH/Assembly-CSharp.dll" "$ONI_PATH/UnityEngine.dll" \
"$ONI_PATH/UnityEngine.CoreModule.dll" "$ONI_PATH/0Harmony.dll"; do
REFS="$REFS -reference:\"$dll\""
done
if [ -f "$ONI_PATH/Assembly-CSharp-firstpass.dll" ]; then
REFS="$REFS -reference:\"$ONI_PATH/Assembly-CSharp-firstpass.dll\""
fi
echo "[Build] Compiling..."
eval mcs -target:library -out:"$OUTPUT_DIR/ONIAgentBridge.dll" $REFS -recurse:"$MOD_DIR/*.cs"
echo "[Build] SUCCESS: $OUTPUT_DIR/ONIAgentBridge.dll"
echo ""
echo "Install (Linux):"
echo " MOD_DIR=~/.config/unity3d/Klei/OxygenNot\\ Included/mods/local/ONIAgentBridge"
echo " mkdir -p \"\$MOD_DIR\""
echo " cp $OUTPUT_DIR/ONIAgentBridge.dll $MOD_DIR/mod_info.yaml \"\$MOD_DIR/\""
echo " # Then enable mod in ONI > Mods > ONI Agent Bridge"