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