Closed DigiWorm0 closed 3 years ago
Here is my csproj file:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
<Version>1.0.0</Version>
<Mappings>NuclearPowered/Mappings:0.2.0</Mappings>
<Description>TestMod</Description>
<Authors>DigiWorm</Authors>
<OutputType>Library</OutputType>
<Platforms>AnyCPU</Platforms>
</PropertyGroup>
<PropertyGroup Condition="'$(GamePlatform)' == 'Steam'">
<GameVersion>2021.3.5s</GameVersion>
<DefineConstants>$(DefineConstants);STEAM</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="'$(GamePlatform)' == 'Itch'">
<GameVersion>2021.3.5i</GameVersion>
<DefineConstants>$(DefineConstants);ITCH</DefineConstants>
</PropertyGroup>
<ItemGroup>
<Deobfuscate Include="$(AmongUs)\BepInEx\plugins\Reactor-$(GameVersion).dll" />
<PackageReference Include="Reactor.OxygenFilter.MSBuild" Version="0.2.9" />
</ItemGroup>
<ItemGroup>
<Compile Update="Properties\Resources.Designer.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Update="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>
<Target Name="Copy" AfterTargets="Reobfuscate">
<Copy SourceFiles="$(OutputPath)reobfuscated/$(AssemblyName)-$(GameVersion).dll" DestinationFolder="$(AmongUs)/BepInEx/plugins/" Condition="'$(Configuration)' == 'Debug'" />
</Target>
</Project>
Solved! Turns out, you need to add the library's dll into BepInEx's plugins folder along with your plugin dll in order for the plugin to find and use it. For Newtonsoft.Json, this dll is located at C:\Users\(Insert Username)\.nuget\packages\newtonsoft.json\13.0.1\lib\netstandard2.0\Newtonsoft.Json.dll
I currently have a working plugin with Reactor. I need a library that can deserialize/serialize json to go with it. No biggie, I can just use Newtonsoft.Json. However, I can't seem to get any external libraries (installed with nuget) to work in combination with Reactor. Newtonsoft.Json seems to act the strangest, likely since it is already referenced by
Reactor.OxygenFilter.MSBuild
.When I have
Newtonsoft.Json 13.0.1
installed, the code compiles and runs without issues. However, as soon as I try to executeJsonConvert.SerializeObject(...)
within the library, BepInEx throws the following exception:Method not found: string Newtonsoft.Json.JsonConvert.SerializeObject(object)
In addition, if I try to use any other library within Reactor, it also compiles/runs fine. However, when I try to execute a function within the library, BepInEx throws the following exception:
Error loading [TestMod 1.0.0] : Could not load file or assembly 'LibraryName, Version=5.0.0.0, Culture=neutral, PublicKeyToken=...' or one of its dependencies.
I have tried using various other libraries, but they all threw the same error. I have also tried compiling manually with
dotnet build
with no success. Is this a problem with Reactor or am I doing something wrong?