I used to combine DLL's in plugins as a part of the Post-Build Event Commands in Visual Studio. The following is a quick article to describe how I used to do this before and what I am currently doing to make them work seamlessly for my automated deployments.
ilmerge is a NuGet package developed by mbarnett. The latest release was in July 2020 and has since been deprecated. Nevertheless, it is quite a useful tool and something that I have been using since a few years whenever I have a requirement to combine multiple dll's such as a custom built dll along with Json.dll
To do this, you can install the ILMerge NuGet package and then use some Post-Build Events as shown below:
cd "D:\Solutions\KushKlix\packages\ILMerge.3.0.18\tools\net452"
ilmerge "D:\Solutions\KushKlix\Vivid\bin\Debug\FvtMailer.dll" "D:\Solutions\KushKlix\Vivid\bin\Debug\Newtonsoft.Json.dll" /out:"D:\Solutions\KushKlix\Vivid\bin\Debug\VividIntegrate.dll" /keyfile:"D:\Solutions\KushKlix\Vivid\MyKey.snk"
Taking the DLL merge up one notch, I found that the NuGet Package MSBuild.ILMerge.Task by Alexander Nosenko comes in extremely handy. I find myself increasingly installing this package (which installs ILMerge in-turn) in projects that have merging requirements. I do not need any Post-Build Events now; as long as the package is installed, the DLL's are automatically merged on build and placed in the project output. The selection criteria for which DLL's among the references are to be merged are determined by the "Copy Local" property of the reference. Where references are marked "Copy Local " true, they are merged. I find this a perfect solution for my automated deployments.