Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question Сan't build a project with error "Fatal error in Unity CIL Linker"

Discussion in 'Scripting' started by andgusaandgusa, Sep 30, 2023.

  1. andgusaandgusa

    andgusaandgusa

    Joined:
    Sep 30, 2023
    Posts:
    3
    Hello. I program at an amateur level and in the evenings I make a "dream game". Sometimes I throw off builds to friends to see how the game works on other systems, and yesterday there was such a problem. I tried to build an empty scene, but the error did not disappear. I tried to build an empty project and there were no problems in it. Can someone help with this problem, because an Internet search did not give anything. I can provide the necessary information, just let me know. Thank you in advance.

    Error:
    Build completed with a result of 'Failed' in 2 seconds (2294 ms)
    Building Library\Bee\artifacts\WinPlayerBuildProgram\ManagedStripped failed with output:
    C:\Program Files\Unity\Hub\Editor\2023.1.10f1\Editor\Data\il2cpp\build\deploy\UnityLinker.exe @Library\Bee\artifacts\rsp\218018006845195562.rsp
    Fatal error in Unity CIL Linker
    Mono.Cecil.AssemblyResolutionException: Failed to resolve assembly: 'nunit.framework, Version=3.5.0.0, Culture=neutral, PublicKeyToken=2638cd05610744eb'
    at Unity.Linker.UnityAssemblyResolver.Resolve(AssemblyNameReference name, ReaderParameters parameters)
    at Unity.IL2CPP.Common.AssemblyDependenciesComponent.CollectAssemblyDependencies(AssemblyDefinition assembly, Boolean throwOnUnresolved)
    at Unity.IL2CPP.Common.AssemblyDependenciesComponent.GetReferencedAssembliesFor(AssemblyDefinition assembly)
    at Unity.Linker.UnityLinkContext.ResolveReferences(AssemblyDefinition assembly)
    at Mono.Linker.Steps.LoadReferencesStep.ProcessReferences(AssemblyDefinition assembly)
    at Mono.Linker.Steps.BaseStep.Process(LinkContext context)
    at Unity.Linker.UnityPipeline.ProcessStep(LinkContext context, IStep step)
    at Mono.Linker.Pipeline.Process(LinkContext context)
    at Unity.Linker.UnityDriver.UnityRun(UnityLinkContext context, UnityPipeline p, LinkRequest linkerOptions, TinyProfiler2 tinyProfiler, ILogger customLogger)
    at Unity.Linker.UnityDriver.RunDriverWithoutErrorHandling(TinyProfiler2 tinyProfiler, ILogger customLogger)
    at Unity.Linker.UnityDriver.RunDriverWithoutErrorHandling()
    at Unity.Linker.UnityDriver.RunDriver()

    UnityEngine.GUIUtility:processEvent (int,intptr,bool&)
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,563
    That's a great first step, actually on my list below.

    Also: be sure to try a full Reimport-All on your project.

    And here's the general list:

    How to troubleshoot build failures:

    First, make a blank project with a single blank scene and prove that it builds successfully.

    If the blank project does NOT build, go fix your Unity installation or your other tools, such as Android SDK, NDK, JDK, etc. It may even be necessary to change to a different version of Unity3D. It is generally best to stay with LTS versions of Unity3D.

    Until you can build a blank project to the target platform, don't fiddle with anything else.

    Once you can build a blank project, now bisect the problem by bringing over parts of your current project and building it one subsystem at a time, perhaps stubbing things out that might trigger compiler errors.

    Most often things that prevent building are third-party libraries such as Firebase.

    Once you identify the subsystem, go to the documentation for it and make sure you are doing it correctly.

    It may also be helpful to work through a tutorial or two for whatever subsystem is making the build fail.

    Android build not building:

    Recently (circa July 2022) there have been reports of Unity's installer failing to install the Android Tools.

    https://forum.unity.com/threads/cant-build-for-android.1306098/

    Here was how I brought up Unity2020.3.41 and the Android SDK 31 on October 30, 2022 (edited on August 23, 2023 to include Android SDK 33...):

    https://forum.unity.com/threads/aab...y-2021-3-8-with-jdk-1-8.1322211/#post-8551193

    Android Gradle errors and other related stuff:

    https://forum.unity.com/threads/unity-gradle-bug-please-help.1368018/#post-8625789
     
    andgusaandgusa likes this.
  3. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    3,899
    NUnit is an editor-only assembly. Check your Assembly Definitions. None of them should reference NUnit. Unity tests do require it but they have a special setup in the asmdef to prevent the assembly from being included in builds. I guess you either modified a unit test asmdef or you made your own test asmdef without taking into account builds.

    Try creating a new test assembly via the Create menu and closely inspect and compare it with any existing test assemblies to be able to correct those. If I remember correctly the key is the scripting symbol that declares the asmdef as a test assembly, and one of the checkboxes.
     
    andgusaandgusa likes this.
  4. andgusaandgusa

    andgusaandgusa

    Joined:
    Sep 30, 2023
    Posts:
    3
    Thank you very much. Indeed, in one script I had a reference to NUnit. I will assume that this is because of intellicode, because sometimes it adds various links on its own.
     
  5. andgusaandgusa

    andgusaandgusa

    Joined:
    Sep 30, 2023
    Posts:
    3
    Thanks for your list. The solution was suggested to me by the person below, but if there are any mistakes in the future, I will use your advice.