I’m building an .NET 4.5 Application which I eventually run through ILMerge to produce a single .exe and a single .exe.config at the end.
I have a post build event which does 2 things.
- Run ILMerge and place the combined assembly in $(ProjectDir)\Lib\
- Xcopy bin\orignial.exe.config => $(ProjectDir)\lib\combined.exe.config
The last step I need to perform is a cleanup of the contents of the config file. Any type+assembly references in the original config need to be replaced stating that type is now located in the new assembly. For example, the app also uses and merges in Unity so in the original.exe.config that section entry is
<section name="unity"
type="Microsoft.Practices.Unity.Configuration.UnityConfigurationSection,
***Microsoft.Practices.Unity.Configuration***" />
Whereas in the merged assembly, it needs to change to
<section name="unity"
type="Microsoft.Practices.Unity.Configuration.UnityConfigurationSection,
***Combined***" />
I know there’s a built in Config File Transformation tool for altering the config file based on the build (Debug/Release) you are performing. Just wondering can this be leveraged for custom purposes or am I going to be stuck hand-crafting some find & replace code.
I’ve decided to use CTT; A command line XDT Transformation tool.
http://ctt.codeplex.com/
http://outcoldman.com/en/blog/show/223
Seems like it’ll do what I need in conjunction with ILMerge.