2
Vote

ILMerge.Merge: ERROR!!: Duplicate type

description

I try to merge all DLL of my library.
When I build, I get this error :
ILMerge.Merge: ERROR!!: Duplicate type 'SolidWorks.Interop.sldworks.DSldWorksEvents' found in assembly 'Solidworks.Helper'. Do you want to use the /alllowDup option?

If I well read I should use allowDup, but I can't how to do on the web ?

I tried <ILMergeAllowDuplicateType>true</ILMergeAllowDuplicateType>, but doesn't change any thinks.

UPDATE:
You can forgot this issue. The problem was with the DLL...

comments

DanPeterson wrote Sep 8, 2016 at 9:52 PM

I am seeing this same issue, and it doesn't appear to support updates to the properties file. I am using Web API in my project causing duplicate types for System.Net.Http.HttpRequestMessageExtensions.

error : ILMerge.Merge: ERROR!!: Duplicate type 'System.Net.Http.HttpRequestMessageExtensions' found in assembly 'System.Web.Http'. Do you want to use the /alllowDup option?

I go to the ILMerge.props file, and I modify the ILMergeAllowDuplicateType setting in the property group. It appears from reading the Microsoft documentation for the /allowDup option that I should list the type names in that setting. E.g.
<ILMergeAllowDuplicateType>System.Net.Http.HttpRequestMessageExtensions</ILMergeAllowDuplicateType>
It doesn't appear to affect the output in any way. Should the name of that property be ILMergeAllowDuplicateTypes? Should I specify a list in there?

fbrem wrote Sep 14, 2016 at 8:24 AM

Hi, we had the same problem. We found the solution in the source code:
 if (!string.IsNullOrEmpty(this.AllowDuplicateType))
            {
                if (this.AllowDuplicateType == "*")
                {
                    merger.AllowDuplicateType(null);
                }
                else
                {
                    foreach (string typeName in this.AllowDuplicateType.Split(','))
                    {
                        merger.AllowDuplicateType(typeName);
                    }
                }
            }
so the working value for us:
<ILMergeAllowDuplicateType>*</ILMergeAllowDuplicateType>