Question Best Practices ILMerge has good information on why.
When I use ILMerge, I use it to create a single DLL to simplify deployment.
As for How, I can define a separate VS custom project, "Converged.csproj", if you like. In this .csproj file, I define a custom compilation target. This is the boilerplate code that ILMerge executes in all referenced assemblies for a project.
It looks like this:
<Target Name="Compile"> <Message Text="Performing the Ilmerge." /> <CreateItem Include="@(_ResolvedProjectReferencePaths)"> <Output TaskParameter="Include" ItemName="AssembliesToMerge" /> </CreateItem> <Message Text="AssembliesToMerge= @(AssembliesToMerge -> '"%(Fullpath)"', ' ')" /> <Message Text="TargetFileName= $(TargetFileName)" /> <Error Text="ILMerge cannot be found. You need to download and install ILMerge in order to build DotNetZip." Condition="!Exists('$(ProgramFiles)\Microsoft\Ilmerge\Ilmerge.exe')" /> <Exec Command=""$(ProgramFiles)\Microsoft\Ilmerge\Ilmerge.exe" /t:library /xmldocs /out:"$(IntermediateOutputPath)$(TargetFileName)" @(AssembliesToMerge -> '"%(Fullpath)"', ' ') " /> <Copy SourceFiles="$(IntermediateOutputPath)$(AssemblyName).XML" DestinationFolder="$(OutDir)" SkipUnchangedFiles="true" OverwriteReadOnlyFiles="$(OverwriteReadOnlyFiles)" /> </Target>
source share