This is a mirror of official site: http://jasper-net.blogspot.com/

ILMerge – How to Merge Assemblies After A Build

| Sunday, November 7, 2010
The other day I mentioned I was working on an API to communicate with Sonic, an enterprise messaging system.  After getting the API to the point where I wanted to send it to some other developers I wanted to package everything up as on DLL.  ILMerge to the rescue!

Sonic provides their own DLLs that were ported from Java for .NET developers.  There are 7 DLLs you have to reference in order to communicate with Sonic.  Here’s how this can be done using ILMerge by simply modifying the project file using an after build target.

The following below does a few things.

It takes all of the assemblies that are outputted to the build directory and passes that to the ILMerge command.
Once they are merged the files are deleted.

<Target Name="AfterBuild">

<CreateItem Include="@(ReferenceCopyLocalPaths)" Condition="'%(Extension)'=='.dll'">
<Output TaskParameter="Include" ItemName="IlmergeAssemblies" />
</CreateItem>
<Exec Command="&amp;quot;$(MSBuildProjectPath)..\..\ThirdPartyAssemblies\Ilmerge\Ilmerge.exe&amp;quot; /allowDup /log /keyfile:$(AssemblyOriginatorKeyFile) /out:@(MainAssembly) &amp;quot;@(IntermediateAssembly)&amp;quot; @(IlmergeAssemblies->'&quot;%(FullPath)&quot;', ' ')" />
<Delete Files="@(ReferenceCopyLocalPaths->'$(OutDir)%(DestinationSubDirectory)%(Filename)%(Extension)')" />
</Target>

Read more: Words of Wisdom From The Elder

Posted via email from .NET Info

0 comments: