BepInEx icon indicating copy to clipboard operation
BepInEx copied to clipboard

Failed to generate Il2Cpp interop assemblies (Gorebox)

Open postredaction opened this issue 1 year ago • 1 comments

What happened?

Happens when launching a new update of Gorebox.

BepInEx Distribution

Bleeding Edge from BepisBuilds

Log outputs

[Message: Preloader] BepInEx 6.0.0-be.692 - GoreBox
[Message: Preloader] Built from commit 851521cc126e4f9d841d2d9bfe857558f0395939
[Info   :   BepInEx] System platform: Windows 10 64-bit
[Info   :   BepInEx] Process bitness: 64-bit (x64)
[Info   :   BepInEx] Running under Unity 2021.3.41f1
[Info   :   BepInEx] Runtime version: 6.0.7
[Info   :   BepInEx] Runtime information: .NET 6.0.7
[Info   :InteropManager] Detected outdated interop assemblies, will regenerate them now
[Message:InteropManager] Downloading unity base libraries
[Error  :InteropManager] Failed to generate Il2Cpp interop assemblies: System.Net.Http.HttpRequestException: Response status code does not indicate success: 404 (Not Found).
   at System.Net.Http.HttpResponseMessage.EnsureSuccessStatusCode()
   at System.Net.Http.HttpClient.GetStreamAsyncCore(HttpRequestMessage request, CancellationToken cancellationToken)
   at BepInEx.Unity.IL2CPP.Il2CppInteropManager.DownloadUnityAssemblies() in /home/runner/work/BepInEx/BepInEx/Runtimes/Unity/BepInEx.Unity.IL2CPP/Il2CppInteropManager.cs:line 272
   at BepInEx.Unity.IL2CPP.Il2CppInteropManager.GenerateInteropAssemblies() in /home/runner/work/BepInEx/BepInEx/Runtimes/Unity/BepInEx.Unity.IL2CPP/Il2CppInteropManager.cs:line 235
[Info   : Preloader] 0 patcher plugins loaded
[Info   : Preloader] 0 assemblies discovered
[Message:AssemblyPatcher] Executing 0 patch(es)
[Message:   BepInEx] Chainloader initialized

Environment

- OS: Windows 11 x64
- BepInEx: BepInEx Unity.IL2CPP win x64 6.0.0-be 692+851521c.zip
- Game: Gorebox

postredaction avatar Jul 31 '24 18:07 postredaction

Replace DownloadUnityAssemblies with

    private static void DownloadUnityAssemblies()
    {
        var unityVersion = UnityInfo.Version;
        var file = $"{unityVersion.Major}.{unityVersion.Minor}.{unityVersion.Build}.zip";

        var baseFolder = Directory.CreateDirectory(UnityBaseLibsDirectory);
        baseFolder.EnumerateFiles("*.dll").Do(a=>a.Delete());
        var target = baseFolder.GetFiles(file).FirstOrDefault();
        if (target != null) {
            using var fStream = target.OpenRead();
            using var zipArchive = new ZipArchive(fStream, ZipArchiveMode.Read);
            zipArchive.ExtractToDirectory(UnityBaseLibsDirectory);
        } else {
            var source = UnityBaseLibrariesSource.Value + file;
            Logger.LogMessage($"Downloading unity base libraries {source}");
            using var httpClient = new HttpClient();
            using var zipStream = httpClient.GetStreamAsync(source).GetAwaiter().GetResult();
            Logger.LogMessage("Extracting downloaded unity base libraries");
            using var zipArchive = new ZipArchive(zipStream, ZipArchiveMode.Read);
            zipArchive.ExtractToDirectory(UnityBaseLibsDirectory);
        }
    }

Then manually download the files and put it in UnityBaseLibsDirectory. I forgot where it actually is because I wrote this ages ago. You can find the link in https://unity.bepinex.dev/libraries. Just find the matching version.

lampuiho avatar Dec 09 '24 03:12 lampuiho