I'll make this as simple as I can, if you need any more info please let me know. I downloaded ILMerge to merge Newtonsoft.Json.dll into my class library. I am invoking ILMerge from the post-build event command line with the following:
"$(ProjectDir)bin\ILMerge.exe" /internalize:"$(ProjectDir)bin\ILMergeIncludes.txt" /out:"$(TargetDir)$(TargetName).all.dll" "$(TargetDir)$(TargetName).dll" "$(TargetDir)*.dll" /target:library /targetplatform:v4,C:\Windows\Microsoft.NET\Framework64\v4.0.30319 /wildcards
In the output window it says:
An exception occurred during merging:
ILMerge.Merge: ERROR!!: Duplicate type 'myLibrary.some.class' found in assembly 'myLibrary.all'. Do you want to use the /alllowDup option?
at ILMerging.ILMerge.MergeInAssembly(AssemblyNode a, Boolean makeNonPublic, Boolean targetAssemblyIsComVisible)
at ILMerging.ILMerge.Merge()
at ILMerging.ILMerge.Main(String[] args)
The problem is that 'myLibrary.some.class' is NOT a duplicate.
I've been all over the internet looking for clues and all I've turned up is the following 2 links, and a few cases of web apps where people have copy/pasted pages and forgot to change the class names.
similar problem with a solution that doesn't seem relevant
same cry for help but with no answers
I've tried using the allowDup option but in the merged dll it turns 'myLibrary.some.class' into 'myLibrary.some.random125624.class'. Then I tried using allowDup passing in 'class' but then I get "Duplicate type" errors for 'class2' and then 'class3' and then 'class4'... there seems to be no end to the number of duplicate types!
I'm certain these classes are not duplicates as the namespace is very specific to my company and project.
Can anyone help?
In your command line you tell ILMerge to use one library tiwce
ILMerge takes all dll-filese in the TargetDir with "$(TargetDir)*.dll" /wildcards
and once again you add the file "$(TargetDir)$(TargetName).dll"
.
So the solution is very simple. Try this commandline:"$(ProjectDir)bin\ILMerge.exe" /internalize:"$(ProjectDir)bin\ILMergeIncludes.txt" /out:"$(TargetDir)$(TargetName).all.dll" "$(TargetDir)*.dll" /target:library /targetplatform:v4,C:\Windows\Microsoft.NET\Framework64\v4.0.30319 /wildcards