Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ILMerge DLL: Assembly not merged in correctly, still listed as an external reference

In the build process for a .NET C# tool, I have been using ILMerge to merge the assemblies into a single exe.

I added a new class library recently, and now the ILMerge is failing. I have remembered to tell it to merge in the new DLL!

It is now giving me this error, which I don't really understand:

ILMerge.Merge: The assembly 'DataObjects' was not merged in correctly. It is still listed as an external reference in the target assembly.

All of the assembly references I have done using 'project' references, and it has not failed in the past.

Can anyone explain this error for me, or suggest a workaround please?

like image 282
Fiona - myaccessible.website Avatar asked Nov 27 '09 09:11

Fiona - myaccessible.website


2 Answers

I had to use the /closed argument. According to the official docs:

Closed

When this is set before calling Merge, then the "transitive closure" of the input assemblies is computed and added to the list of input assemblies. An assembly is considered part of the transitive closure if it is referenced, either directly or indirectly, from one of the originally specified input assemblies and it has an external reference to one of the input assemblies, or one of the assemblies that has such a reference. Complicated, but that is life...

like image 162
Fiona - myaccessible.website Avatar answered Oct 14 '22 00:10

Fiona - myaccessible.website


I got a similar error message when trying to publish a web app that merged all outputs to a single assembly:

An error occurred when merging assemblies: ILMerge.Merge: The target assembly lists itself as an external reference.

This happens if the assembly name you are merging to matches the assembly name of the web application under Properties > Application. Changing the output assembly name should fix it.

like image 7
Hugh Jeffner Avatar answered Oct 14 '22 00:10

Hugh Jeffner