Sunday, November 29, 2015

ILMerge Command Line Syntax

I had cause the other day to use ILMerge to combine several DLLs. The first issue I came across was:

Unresolved assembly reference not allowed: System.Core.

This is mentioned in several blogs and the solution suggested was to use the /lib switch and specify the path to the .NET library you want for the target. In my case I wanted to target 4.5.2 so I used the following which supposedly worked (the blog said)

ilmerge  /lib:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.2"   /out:MERGED.First.dll  First.dll Second.dll  /keyfile:key.snk

Note that if you strongly signed your First DLL don't assume the output will be strongly signed because it won't be. You have to add the /keyfile option to do that. 

Note also there are blogs that say don't try and point to C:\Windows... because that is not the correct location.  You need to use the Reference Assemblies path given above.

Well I didn't get the error and ILMerge started off and I waited. And waited. And waited.  So basically ILMerge just hangs still consuming by the way 50% CPU just to fool you into thinking its actually doing something. 

Its the wrong syntax. The correct syntax uses /targetplatform not /lib

ilmerge  /targetplatform:v4,"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.2"   /out:MERGED.First.dll  First.dll Second.dll /keyfile:key.snk

No comments: