ILMerge in MSBuild

ILMerge in MSBuild

  • Comments 2


<!--
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>

Leave a Comment
  • Please add 5 and 3 and type the answer here:
  • Post
  • Jomo Fisher--Over the last few years I've been coding mostly in C#--before that, my day-to-day work was...
  • 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!

Page 1 of 1 (2 items)