Welcome to MSDN Blogs Sign in | Join | Help

ILMerge in MSBuild


<!--
Use of included script samples are subject to the terms specified at http://www.microsoft.com/resources/sharedsource/licensingbasics/permissivelicense.mspx

Written by Jomo Fisher
-->
<Project
 DefaultTargets="Build"
 xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

 <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />

 <Target Name="AfterBuild">
   <CreateItem Include="@(ReferencePath)" Condition="'%(CopyLocal)'=='true'">
       <Output TaskParameter="Include" ItemName="IlmergeAssemblies"/>
   </CreateItem>
   <Exec Command="&quot;$(ProgramFiles)\Microsoft\Ilmerge\Ilmerge.exe&quot; /out:@(MainAssembly) &quot;@(IntermediateAssembly)&quot; @(IlmergeAssemblies->'&quot;%(FullPath)&quot;', ' ')"/>
   <!--Delete Files="@(ReferenceCopyLocalPaths->'$(OutDir)%(DestinationSubDirectory)%(Filename)%(Extension)')"/-->
 </Target>

 <Target Name="_CopyFilesMarkedCopyLocal"/>

</Project>

Published Sunday, March 05, 2006 5:31 PM by Jomo Fisher

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

# Hack the Build: Use ILMerge and MSBuild to Combine Multiple Assemblies into One

Jomo Fisher--Over the last few years I've been coding mostly in C#--before that, my day-to-day work was...
Sunday, March 05, 2006 5:33 PM by Jomo Fisher

# re: ILMerge in MSBuild

I realise this is just something you came up in your spare time but one shortcoming is that this task will execute on every build because there is no InputFiles/OutputFiles specified for the task.

Furthermore, specifying these values correctly is tricky because you're overwriting an existing build output file when you do the ILMerge, so if you're not careful you could get into a position where the task never runs because it sees the (non-yet-merged) output file is up to date!

Thursday, December 24, 2009 3:42 AM by Daniel Fortunov

Leave a Comment

(required) 
required 
(required) 

  
Enter Code Here: Required
 
Page view tracker