title: .NET assembly merge troubleshooting ilmerge
body: <p>searching for a tool to merge .NET assemblies I always endup in trying <code>ILMerge</code>. But I don't get it working. Now I tried just a very simple example that doesn't work.</p>
  
  <p>My library containing only this interface:</p>
  
  <pre><code>namespace CommonLib
  {
      public interface IPlugin
      {
          string Name { get; }
          string Version { get; }
          void Load();
      }
  }
  </code></pre>
  
  <p>My console application contains the class:</p>
  
  <pre><code>using System;
  using CommonLib;
  
  namespace ILMergeTest
  {
      internal class DirectTestPlugin : IPlugin
      {
          public string Name =&gt; "DirectTestPlugin";
          public string Version =&gt; "4711.0.8.15";
          public void Load()
          {
              Console.WriteLine("Loading Plugin: " + Name + " [Version " + Version + "]");
          }
      }
  }
  </code></pre>
  
  <p>and the Program.cs</p>
  
  <pre><code>using System;
  
  namespace ILMergeTest
  {
      internal class Program
      {
          private static void Main(string[] args)
          {
              var plugin = new DirectTestPlugin();
              plugin.Load();
              Console.ReadKey();
          }
      }
  }
  </code></pre>
  
  <p>After compiling the application everything works fine.</p>
  
  <p>Now I copy ILMerge.exe to the output directory, where my binaries are and create the following batch to perform ILMerge</p>
  
  <pre><code>mkdir Merged
  
  ilmerge /union /ndebug /t:exe /copyattrs /closed /out:Merged\MergedProgram.exe /targetplatform:v4,"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1" "ILMergeTest.exe" "CommonLib.dll"
  pause
  </code></pre>
  
  <p>My projects target Framework is <code>.NET 4.6.1.</code></p>
  
  <p>I always get the following error: </p>
  
  <blockquote>
    <p>ILMerge.Merge: The assembly 'CommonLib' was not merged in correctly.
    It is still listed as an external reference in the target assembly.<br>
    bei ILMerging.ILMerge.Merge()    bei ILMerging.ILMerge.Main(String[]
    args)</p>
  </blockquote>
  
  <p>How do I fix this? The documentation of ILMerge didn't help me at all.</p>
  
  <p>Thanks</p>