NuclearPowered / Reactor

Modding api for Among Us
https://reactor.gg
GNU Lesser General Public License v3.0
225 stars 43 forks source link

Error when building mod #29

Closed Aaryam closed 3 years ago

Aaryam commented 3 years ago

I started with Among Us mod making a few days ago, I set everything up and followed the instructions and everything worked. I could build my mods and it would display / work as intended. Today, out of the blue a lot of errors started showing up. The root of this (I found) was this: ` Severity Code Description Project File Line Suppression State Error MSB4018 The "GenerateReferences" task failed unexpectedly. System.IO.FileNotFoundException: Could not load file or assembly 'Mono.Cecil, Version=0.11.2.0, Culture=neutral, PublicKeyToken=50cebf1cceb9d05e' or one of its dependencies. The system cannot find the file specified. File name: 'Mono.Cecil, Version=0.11.2.0, Culture=neutral, PublicKeyToken=50cebf1cceb9d05e' at Il2CppDumper.DummyAssemblyExporter.Export(Il2CppExecutor il2CppExecutor, String outputDir, Boolean addToken) at Il2CppDumper.Il2CppDumper.PerformDump(String gameAssemblyPath, String metadataDatPath, String outputDirectoryPath, Config config, Action1 reportProgressAction) at Reactor.OxygenFilter.MSBuild.GenerateReferences.Execute() in /home/js6pak/Development/AmongUs/Reactor.OxygenFilter/Reactor.OxygenFilter.MSBuild/GenerateReferences.cs:line 56 at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute() at Microsoft.Build.BackEnd.TaskBuilder.d__26.MoveNext()

WRN: Assembly binding logging is turned OFF. To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1. Note: There is some performance penalty associated with assembly bind failure logging. To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].xx ``

Is this something on my part?

SteamUnlocked21 commented 3 years ago

Have you tried dotnet build ? Also, is the Reactor.OxygenFilter version and NuclearPowered/Mappings version correctly matching with the game version ?

Game Version :- 2021.4.12s Mappings :- 0.4.0 Reactor.OxygenFilter :- 0.3.0

If the above is correct, then try the command prompt command 'dotnet build' .

Aaryam commented 3 years ago

I have tried dotnet build, and all the above mappings but the error still shows up

Aaryam commented 3 years ago

With the research I have done over the last 4 days, I have concluded that it's something to do with Mono.Cecil not working as intended / not being referenced by 'GenerateReferences'. So this is a problem with Reactor.OxygenFilter

ItzNotLanky commented 3 years ago

I have also had this problem for the past many days, i think it's an issue with the OxygenFilter but idk

DaemonBeast commented 3 years ago

EDIT: it seems that the mappings were updated and they should now work for v2021.4.14s. No need to follow one of these solutions. Ensure the mappings are set to NuclearPowered/Mappings:0.4.0, game version is set to 2021.4.14s and ensure you have the newest version of Reactor (https://github.com/NuclearPowered/Reactor/actions).


This assumes you have the steam version of the game, not the itch version.

Make sure you only follow ONE of the approaches; doing both will NOT work.

Mappings Approach

An easier approach might be to change the mappings in the configuration file from NuclearPowered/Mappings:0.4.0 to XtraCube/Mappings:0.4.1. You will also need to ensure that the configuration file contains the Among Us version 2021.4.14s and you'll need to change the name of the Reactor dll in your game's plugins folder from Reactor-2021.4.12s to Reactor-2021.4.14s. Ensure you change your AmongUs environment variable back to the directory of your v2021.4.14s install as well if necessary. If errors persist (usually from environment variables not updating), try restarting your IDE.

Alternative Approach

It's probably due to the fact that you're trying to build for 2021.4.12s despite your AmongUs environment variable pointing to the directory of your 2021.4.14s install of Among Us. At the moment, you can't use OxygenFilter with 2021.4.14s, so you have to build for 2021.4.12s then transfer the plugins over.

In order to get OxygenFilter working, you need to do the following:

  1. Set up a 2021.4.12s install of Among Us, using DepotDownloader if necessary (install 2021.4.12s using the command dotnet DepotDownloader.dll -app 945360 -depot 945361 -manifest 2725166875026424465).
  2. Set up BepInEx and Reactor as usual in the 2021.4.12s game's directory, ensuring you launch the game at least once after installing BepInEx and Reactor.
  3. Create a file called steam_appid.txt with the contents 945360 and save it in the 2021.4.12s game's directory.
  4. Change your AmongUs environment variable to the 2021.4.12s game's directory.
  5. Ensure your mod's configuration file (PROJECT_NAME.csproj) has mappings set to version 0.4.0, Among Us set to version 2021.4.12s and OxygenFilter set to version 0.3.0.
  6. Run dotnet build in a cmd/terminal in the solution directory of your mod (where the .sln file is).
  7. If all compiles fine, restart your IDE just to clear out any caching and you should be able to compile your mod in your IDE again.

Note: mods will be compiled to the 2021.4.12s game's plugins folder, so you'll either have to copy it over manually after compiling or automate copying it over by adding the line <Copy SourceFiles="$(OutputPath)reobfuscated/$(AssemblyName)-$(GameVersion).dll" DestinationFolder="DIRECTORY_OF_YOUR_2021.4.14s_GAME'S_PLUGINS_FOLDER" /> in the <Target Name="Copy" AfterTargets="Reobfuscate"> block at the bottom of your configuration file. Remember to remove this if you're going to release the mod, or use an environment variable instead to store the directory path.

Aaryam commented 3 years ago

It works! Thank you so much!

ExpertStatue commented 3 years ago

my have same error and this wont work with the new among us i think can you help

DaemonBeast commented 3 years ago

@Cheesepuff1 Use something like this as your csproj instead (replacing fields as necessary):

<Project Sdk="Microsoft.NET.Sdk">
    <PropertyGroup>
        <TargetFramework>netstandard2.1</TargetFramework>
        <Version>...</Version>

        <Description>...</Description>
        <Authors>...</Authors>
    </PropertyGroup>

    <Target Name="Copy" AfterTargets="Build">
        <Copy SourceFiles="$(OutputPath)$(AssemblyName).dll" DestinationFiles="$(AmongUs)/BepInEx/plugins/$(AssemblyName)-$(Version).dll" />
    </Target>

    <ItemGroup>
        <Reference Include="$(AmongUs)\BepInEx\core\*.dll">
            <Private>false</Private>
        </Reference>

        <Reference Include="$(AmongUs)\BepInEx\unhollowed\*.dll">
            <Private>false</Private>
        </Reference>

        <Reference Remove="$(AmongUs)\BepInEx\unhollowed\netstandard.dll;$(AmongUs)\BepInEx\unhollowed\Newtonsoft.Json.dll" />

        <Reference Include="$(AmongUs)\BepInEx\plugins\Reactor.dll" />
    </ItemGroup>
</Project>