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)
This commit is contained in:
@ -2,31 +2,15 @@
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net471</TargetFramework>
|
||||
<AssemblyName>ONIAgentBridge</AssemblyName>
|
||||
<Version>1.0.0</Version>
|
||||
<RootNamespace>ONIAgentBridge</RootNamespace>
|
||||
<LangVersion>7</LangVersion>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<Nullable>disable</Nullable>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Lib.Harmony" Version="2.2.2" />
|
||||
<PackageReference Include="System.Text.Json" Version="6.0.0" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<!-- Point these to your ONI installation directory -->
|
||||
<Reference Include="Assembly-CSharp">
|
||||
<HintPath>$(ONI_Path)/Assembly-CSharp.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="Assembly-CSharp-firstpass">
|
||||
<HintPath>$(ONI_Path)/Assembly-CSharp-firstpass.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="UnityEngine">
|
||||
<HintPath>$(ONI_Path)/UnityEngine.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="UnityEngine.CoreModule">
|
||||
<HintPath>$(ONI_Path)/UnityEngine.CoreModule.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="0Harmony" HintPath="$(ONI_Path)\0Harmony.dll" Private="False" />
|
||||
<Reference Include="Assembly-CSharp" HintPath="$(ONI_Path)\Assembly-CSharp.dll" Private="False" />
|
||||
<Reference Include="Assembly-CSharp-firstpass" HintPath="$(ONI_Path)\Assembly-CSharp-firstpass.dll" Private="False" />
|
||||
<Reference Include="UnityEngine" HintPath="$(ONI_Path)\UnityEngine.dll" Private="False" />
|
||||
<Reference Include="UnityEngine.CoreModule" HintPath="$(ONI_Path)\UnityEngine.CoreModule.dll" Private="False" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
||||
@ -5,65 +5,57 @@
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
||||
MOD_DIR="$SCRIPT_DIR/mod"
|
||||
PROJECT_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"
|
||||
MOD_DIR="$PROJECT_DIR/mod"
|
||||
OUTPUT_DIR="$MOD_DIR/bin"
|
||||
|
||||
# Find ONI installation
|
||||
ONI_PATH="${ONI_PATH:-}"
|
||||
if [ -z "$ONI_PATH" ]; then
|
||||
# Common paths
|
||||
for candidate in \
|
||||
"$HOME/.steam/steam/steamapps/common/OxygenNotIncluded" \
|
||||
"$HOME/.local/share/Steam/steamapps/common/OxygenNotIncluded" \
|
||||
"$HOME/Library/Application Support/Steam/steamapps/common/OxygenNotIncluded" \
|
||||
"/c/Program Files (x86)/Steam/steamapps/common/OxygenNotIncluded" \
|
||||
"/mnt/c/Program Files (x86)/Steam/steamapps/common/OxygenNotIncluded"; do
|
||||
if [ -d "$candidate" ]; then
|
||||
ONI_PATH="$candidate"
|
||||
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. Set ONI_PATH environment variable."
|
||||
echo " export ONI_PATH=/path/to/OxygenNotIncluded"
|
||||
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 path: $ONI_PATH"
|
||||
echo "[Build] ONI: $ONI_PATH"
|
||||
|
||||
# Check required DLLs
|
||||
GAME_DLLS=(
|
||||
"$ONI_PATH/Assembly-CSharp.dll"
|
||||
"$ONI_PATH/Assembly-CSharp-firstpass.dll"
|
||||
"$ONI_PATH/UnityEngine.dll"
|
||||
"$ONI_PATH/UnityEngine.CoreModule.dll"
|
||||
"$ONI_PATH/0Harmony.dll"
|
||||
)
|
||||
|
||||
for dll in "${GAME_DLLS[@]}"; do
|
||||
if [ ! -f "$dll" ]; then
|
||||
echo "[!] Required DLL not found: $dll"
|
||||
exit 1
|
||||
fi
|
||||
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
|
||||
|
||||
echo "[Build] Found all required DLLs"
|
||||
|
||||
mkdir -p "$OUTPUT_DIR"
|
||||
|
||||
# Compile
|
||||
mcs -target:library \
|
||||
-out:"$OUTPUT_DIR/ONIAgentBridge.dll" \
|
||||
-reference:"$ONI_PATH/Assembly-CSharp.dll" \
|
||||
-reference:"$ONI_PATH/Assembly-CSharp-firstpass.dll" \
|
||||
-reference:"$ONI_PATH/UnityEngine.dll" \
|
||||
-reference:"$ONI_PATH/UnityEngine.CoreModule.dll" \
|
||||
-reference:"$ONI_PATH/0Harmony.dll" \
|
||||
-recurse:"$MOD_DIR/*.cs"
|
||||
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] Compilation successful!"
|
||||
echo "[Build] Output: $OUTPUT_DIR/ONIAgentBridge.dll"
|
||||
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 "To install: copy $OUTPUT_DIR/ONIAgentBridge.dll and $MOD_DIR/mod_info.yaml"
|
||||
echo " to your ONI mods/local/ONIAgentBridge/ directory"
|
||||
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"
|
||||
|
||||
Reference in New Issue
Block a user