Solution for IL2CPP build failing with 'AssemblyResolutionException: Failed to resolve assembly: Assembly-CSharp'

Hi.

I spent way too much time fixing an issue I had when trying to build my project using IL2CPP, but I finally managed to make it work and wanted to share the solution in case anyone encounters this problem in the future. When investigating this issue I spent hours looking through forums/Reddit/etc. and did not find even one mention of the problem, let alone any talk about a possible solution.

Basically, if this is the error you see in Editor.log when building your project with IL2CPP…

Fatal error in Unity CIL Linker
Mono.Cecil.AssemblyResolutionException: Failed to resolve assembly: 'Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'
 ---> Mono.Cecil.AssemblyResolutionException: Failed to resolve assembly: 'Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'

… then make sure that your root project directory does not contain any empty files whose names are similar to either your own assemblies or Unity’s assemblies (example from my case below):

As you can see, they are all empty and have no extension - all of those were in root directory and there was one file for each .csproj. I have no idea where they came from, I did not create them, I had them in my repository since the very first commit.

Removing all those empty files fixed the problem.

To figure this out I had to re-make the entire project and copy every asset one-by-one and seeing if it still compiles and then (once all assets were copied) I did a git diff to see what was different between those two projects. It was a very tedious job to do.

@ScottHFerguson I’m tagging you because I’ve seen that you sometimes reply in IL2CPP-related topics. It would be nice if you could ask the correct person or shed some light regarding what those empty files are supposed to be and why they would cause such an issue + in case of other linker issues, is there any way to enable a more ‘verbose’ logging mode for UnityLinker?

Those files with no extension make no sense. I have no idea what would have created them; nothing in Unity should have. And I can’t see why they would have caused an error in UnityLinker.

All I can really say is if you can reproduce this submit an issue and we could investigate.