The “MSBuild ILMerge task” (or MSBuild.ILMerge.Task
) NuGet package makes this process quite simple. It defaults to merging any “copy local” references into your main assembly.
Note: Although the packages have similar names, this one is different from ILMerge.MSBuild.Tasks
that Davide Icardi mentioned in his answer. The one I’m suggesting here was first published in August 2014.