Trinition
Trinition

Reputation: 1173

Is it possible to successfully merge transitive assembly references with ILMerge?

I'm trying to use ILMerge to internalize some transitively referenced assemblies into an assembly I'm referencing to eliminate conflicts with those transitive dependencies elsehwere in my project.

In particular, I'm referencing Antlr3.StringTemplate (hereafter referred to as AS, available here: http://www.stringtemplate.org/download.html). It references Antlr3.Runtime.Debug (ARD) and Antlr3.Runtime (AR). ARD itself also references AR. In ASCII-art, that's:

AS ---> ARD
\        |
 \       v
  \---> AR

Because another assembly I'm using, NHibernate 2.1, depends on different, incompatible version of AR, I wanted to use ILMerge to merge and internalize AR into AS. In theory, I think this should work; however, I'm having trouble executing the theory.

No matter what permutations and options I try, I end up with an error of the following form:

ILMerge.Merge: The assembly 'Antlr3.Runtime.Debug' was not merged in correctly. It is still listed as an external reference in the target assembly.

Is what I'm trying to accomplish with ILMerge even possible?

Upvotes: 3

Views: 3648

Answers (3)

DanB
DanB

Reputation: 1060

I ended up having to ILMerge all of my Nhibernate related .dlls into one to get it to sit nicely with StringTemplate. Probably not the answer you were hoping for but it works.

Upvotes: 0

Stephen Cleary
Stephen Cleary

Reputation: 456717

The most recent version of ILMerge has a /closed option which works on the transitive closure of the merged assemblies. It solves this exact problem (see sections 2.6 Closed and 4.1 Input assembly not merged in correctly in the ILMerge.doc user manual).

Upvotes: 5

peanutbutter_lou
peanutbutter_lou

Reputation: 671

When you run ILMerge from the command line (or within an MSBuild task), of all the assembly files you list out to be merged, it is the first one that is considered the primary assembly when the merging begins. If you haven't already, ensure that the AS assembly filename is listed first in you list of merging assemblies.

Upvotes: 5

Related Questions