I have the following post build event which should pack all the .NET framework dependencies into the .exe:
$(SolutionDir)packages\ILRepack.2.0.16\tools\ILRepack.exe
/out:"$(TargetDir)$(TargetName).all.exe"
"$(TargetDir)$(TargetName).exe"
"$(TargetDir)*.dll"
/target:exe
/targetplatform:v4,"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2" /wildcards
But it must not be packing everything, since when I run it inside a barebones Windows 7 x64 VM, a popup says .NET is required. After installing .NET 4.7.2 everything works fine.
Here is the ILRepack output:
4>------ Rebuild All started: Project: GenerateReport, Configuration: Release Any CPU ------
4> GenerateReport -> C:\code\Thor\Main\pc\tools\ReportGenerator\GenerateReport\bin\Release\GenerateReport.exe
4> INFO: IL Repack - Version 2.0.16
4> INFO: ------------- IL Repack Arguments -------------
4> /out:C:\code\Thor\Main\pc\tools\ReportGenerator\GenerateReport\bin\Release\GenerateReport.all.exe C:\code\Thor\Main\pc\tools\ReportGenerator\GenerateReport\bin\Release\GenerateReport.exe C:\code\Thor\Main\pc\tools\ReportGenerator\GenerateReport\bin\Release\*.dll
4> -----------------------------------------------
4> INFO: Adding assembly for merge: C:\code\Thor\Main\pc\tools\ReportGenerator\GenerateReport\bin\Release\GenerateReport.exe
4> INFO: Adding assembly for merge: C:\code\Thor\Main\pc\tools\ReportGenerator\GenerateReport\bin\Release\ICSharpCode.SharpZipLib.dll
4> INFO: Adding assembly for merge: C:\code\Thor\Main\pc\tools\ReportGenerator\GenerateReport\bin\Release\MDIData.dll
4> INFO: Adding assembly for merge: C:\code\Thor\Main\pc\tools\ReportGenerator\GenerateReport\bin\Release\MDIReporter.dll
4> INFO: Processing references
4> INFO: Processing types
4> INFO: Merging <Module>
4> INFO: Merging <Module>
4> INFO: Merging <Module>
4> INFO: Renaming <PrivateImplementationDetails> into <ea0a2b3c-dc31-41d4-9795-6271bac3aa6b><PrivateImplementationDetails>
4> INFO: Merging <Module>
4> INFO: Processing exported types
4> INFO: Processing resources
4> INFO: Fixing references
4> INFO: Writing output assembly to disk
4> INFO: Finished in 00:00:02.2785005
This is a C# console app built with "Any CPU".
The other two projects in my solution are .NET 4.7.2 desktop class libraries.
I've also tried ILMerge, but it fails with a reference to a thirdy party library that it can't follow. That reference I have embedded as a resource in my application and it works fine.