2

I try to build a single-executable self-hosted application with Web API. I started using OWIN and katana, but were not able to merge them in the end. So I made a very tiny sample project without OWIN and katana, Web API only.

In my output folder I get these files:

  • Newtonsoft.Json.dll
  • System.Net.Http.Formatting.dll
  • System.Web.Http.dll
  • System.Web.Http.SelfHost.dll

and of course the console app itself, in this case:

  • WebAPI_self_hosted.exe

If I copy all 5 files to a different machinge, everything works fine.

When I try to ILMerge them, I get the following error:

ILMerge.Merge: ERROR!!: Duplicate type 'System.Net.Http.HttpRequestMessageExtensions' found in
assembly 'System.Web.Http.SelfHost'. 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)

Please excuse me, if this question is not really up to stackoverflow standards, but I tried a lot the last two days (even ilrepack) and right now, I am thankful for every hint :-)

See also this post with projects attached: Error 2 The type <T> exists in both... with ILMerge

Community
  • 1
  • 1
Xan-Kun Clark-Davis
  • 2,664
  • 2
  • 27
  • 38
  • 1
    There are duplicate types so you need to configure ILMerge to properly handle them, such as using /allowDup option. The error message says it all. – Lex Li Apr 30 '15 at 02:38
  • Hei Li! :-) Thanks for the answer (although it's a comment, so I can't mark it at the answer). It really was the /allowDup. There were also other parameters in the commandline but it works great with the /allowDup as the only parameter. Now I just have to figure out how to use it with the ILMerge Task :-) – Xan-Kun Clark-Davis Apr 30 '15 at 10:34
  • I copied it to an answer. You might accept it to help others locate the proper info. – Lex Li Apr 30 '15 at 10:43
  • it was a pleasure :-) – Xan-Kun Clark-Davis May 01 '15 at 11:26

2 Answers2

1

Disclaimer: This is not an original answer

For those of you using the MSBuild ILMerge task (https://ilmergemsbuild.codeplex.com/), to ignore duplicate types, the ILMerge.props file should have the value as "*" (to ignore ALL types)

<ILMergeAllowDuplicateType>*</ILMergeAllowDuplicateType>

Source: MSBuild.ILMerge.Task not allowing Duplicate Types

Subbu
  • 2,130
  • 1
  • 19
  • 28
0

There are duplicate types so you need to configure ILMerge to properly handle them, such as using /allowDup option. The error message says it all.

Lex Li
  • 60,503
  • 9
  • 116
  • 147