<!--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=""$(ProgramFiles)\Microsoft\Ilmerge\Ilmerge.exe" /out:@(MainAssembly) "@(IntermediateAssembly)" @(IlmergeAssemblies->'"%(FullPath)"', ' ')"/> <!--Delete Files="@(ReferenceCopyLocalPaths->'$(OutDir)%(DestinationSubDirectory)%(Filename)%(Extension)')"/--> </Target>
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!