Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to only merge a subset of dependencies using ILMerge?

Tags:

c#

ilmerge

I'm trying something exploratory:

Say I have a library "coolproject" and it has dependencies to one.dll, two.dll, and three.dll.

I would like to use ILMerge to combine coolproject with one.dll and two.dll but NOT three.dll. At the completion of the merge I should have coolproject.dll and three.dll. Wherever I intend to use coolproject.dll I must also reference three.dll

Is this even possible? Whenever I try it I get. Unresolved assembly reference not allowed: three. I'm omitting three.dll by setting "Copy Local" = false.

[EDIT]:

Executed as the following:

ILMerge /targetplatform:v2 /log /internalize /out:bin\coolproject.dll obj\Debug\coolproject.dll C:\Users\Nick\Projects\test\bin\one.dll C:\Users\Nick\Projects\test\bin\two.dll
like image 836
NickSuperb Avatar asked Jan 24 '13 19:01

NickSuperb


1 Answers

The reason this does not work ended up being rather simple: ILMerge must be able to locate the dll that you have omitted from the list.

When evaluating dependencies in the target library, ILMerge by default checks various locations to identify the dependent library (\bin, GAC, etc) even if you omitted it from the command line list. If it cannot locate this library you must specify its location using the \lib switch. Otherwise you will see the Unresolved assembly reference not allowed: three error.

Example:

ILMerge /lib:..\three\bin\three.dll /targetplatform:v2 /log /internalize /out:bin\coolproject.dll obj\Debug\coolproject.dll C:\Users\Nick\Projects\test\bin\one.dll C:\Users\Nick\Projects\test\bin\two.dll
like image 191
NickSuperb Avatar answered Oct 20 '22 05:10

NickSuperb