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 Unity thinks that an ILMerged dotnet DLL is an EXE file

Discussion in 'WebGL' started by OndrejNepozitek, Apr 7, 2021.

  1. OndrejNepozitek

    OndrejNepozitek

    Joined:
    May 1, 2017
    Posts:
    11
    I'm the author of 2 projects for a procedural level generation - Edgar-DotNet and Edgar-Unity. The Unity version of the project references the .NET version and adds some additional logic so that the generator works in Unity. The .NET library consists of multiple DLL files and targets .NET Standard. Initially, I just added all the DLL files to the Unity asset and everything was working fine. The problem is that the .NET library references some 3rd party libraries (like Json.NET) so there's a potential for collisions between the dependencies if a user decides that they also want to have some of the dependencies in their project. To fix this problem, I decided to use ILMerge to merge all the DLL files from Edgar-DotNet into a single DLL file called EdgarSingleFile.dll. The advantage of this approach is that I can configure ILMerge to make all 3rd party dependencies invisible to the outside world. Everything works great when I build the Unity asset for PC.

    The problem is that I cannot build the asset for WebGL. When I try to do that on Unity 2018.4.18f1, I get this error:

    The error says that Unity cannot find the EdgarSingleFile.dll in the StagingArea folder. And that's correct - the file is not there. However, there's a file called EdgarSingleFile.exe (see the wrong extension). So it seems to me that at some point Unity evaluated that the ILMerged EdgarSingleFile.dll is actually an EXE file and copied the file with a wrong extension to the StagingArea.

    I tried to do the same thing in Unity 2020 and the result was the same, just with a slightly different error message. Then when I tried to build the same project but with all the small DLL files instead of the ILMerged file, everything worked great. So it really seems that the DLL is the problem.

    If you want to see the DLL, you can find it on github.

    Does anyone know how to solve this problem? Is there some flag in the ILMerged DLL that tricks Unity into thinking that it's an EXE file instead of a DLL? Or is there any other way to prevent the problem with multiple versions of the same 3rd party DLL being referenced in a project?
     
  2. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,773
    I don't expect that Unity would rename a .dll file to .exe when it is copied to the staging area, but maybe that is happening. Can you submit a bug report for this issue?
     
  3. OndrejNepozitek

    OndrejNepozitek

    Joined:
    May 1, 2017
    Posts:
    11
    I submitted a bug report. As the described problem does not happen with "normal" DLLs, I'd be also happy to know how to change the DLL so that it doesn't trigger this problem and I can fix the WebGL build for all the users of my asset.
     
    JoshPeterson likes this.
  4. brian-taylor

    brian-taylor

    Unity Technologies

    Joined:
    Aug 2, 2019
    Posts:
    9