Game works fine in editor, but build fails with 59 error in the console

My game works fine and as expected in the unity editor, but upon building i get a ton of errors.
These are the last ones:

Error building Player: 38 errors

Build completed with a result of 'Failed' in 8 seconds (8430 ms)
UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)

UnityEditor.BuildPlayerWindow+BuildMethodException: 41 errors
  at UnityEditor.BuildPlayerWindow+DefaultBuildMethods.BuildPlayer (UnityEditor.BuildPlayerOptions options) [0x002ca] in :0 
  at UnityEditor.BuildPlayerWindow.CallBuildMethods (System.Boolean askForBuildLocation, UnityEditor.BuildOptions defaultBuildOptions) [0x00080] in :0 
UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)

Also this error keeps repeating itself:

Assertion failed on expression: 'false'
UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)

Honorable mentions:

Unhandled exception. System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)

 ---> System.IO.DirectoryNotFoundException: Could not find a part of the path 'C:\Users\(directory)\Documents\UnityGamesProjects\(game)\Library\ScriptAssemblies\Assembly-CSharp.dll'.
UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)

   at System.IO.FileStream.ValidateFileHandle(SafeFileHandle fileHandle)
UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)

   at System.IO.FileStream.CreateFileOpenHandle(FileMode mode, FileShare share, FileOptions options)
UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)

   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)
UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)

Edit: don’t know if it helps, but i had put the unity project in the recycle bin without emptying it and removed it from unity hub due to stress and stuff not working correctly. once i figured out what to do, i restored the folder to the original location and re-added it in unity hub. then it couldn’t build. i haven’t tried building it before i deleted it, but i can try building a different project to see if my pc is the problem, unity or just that project

For anyone who might be stuck with this in the future:

The issue in this case was that AnimationClips in the models import settings didn’t have any names, so the animations weren’t attaching correctly when building the game. So go into the model import settings > animations and make sure that all clips are named before using them.

For anyone who’s still stuck, for me the solution was making sure there’s no unusual characters in your folder names.

My game had a an ’ in it and removing that from one of the folder names solved everything.