I have a console application which is referencing other projects in solution. When I build it, it will copy those dlls in Debug. I want to import them in the exe. If I add them to resources then load from there, they are not updated. I lose the changes on referenced DLLs. Is there a way that I can build them and import them in the executable file on each build?
I have a console application which is referencing other projects in solution. When I
Share
Here’s the solution that worked for me:
http://www.hanselman.com/blog/MixingLanguagesInASingleAssemblyInVisualStudioSeamlesslyWithILMergeAndMSBuild.aspx
It merges assemblies after each build with ILMerge (like suggested in comments). I needed to update .targets file for .NET Framework 4. In case anyone needs it:
Update
While the solution above works, you can make it simpler and you wouldn’t need the targets files. You can put ILMerge somewhere in solution. Then call it from there after build. ILMerge.exe is all you need, copy it in somewhere like
/solutionDirectory/Tools. Write a command in your post-build event command line.After the build, you get the .exe with embedded DLLs and you can run it alone.