views:

561

answers:

2

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?

A: 

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.

peanutbutter_lou
+1  A: 

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).

Stephen Cleary