Thursday, July 23, 2015

HowTo: Make CRM Developer Toolkit & ILMerge work together

Just a quick note. Following post-build script automates merging of custom assemblies you’ve references in your code and the same time allows CRM Developer Toolkit to pick-up merged assembly for deployment:
mkdir "$(TargetDir)Merged" 
"$(SolutionDir)ILMerge/ilmerge.exe" /keyfile:"$(ProjectDir)key.snk" /target:library 
    /copyattrs /targetplatform:v4,"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0" 
    /out:"$(TargetDir)Merged\$(TargetFileName)" "$(TargetDir)$(TargetFileName)" 
    "$(TargetDir)Microsoft.Web.Services2.dll" /lib:"$(ProjectDir)bin\debug"
del "$(TargetDir)$(TargetFileName)" /Q
move "$(TargetDir)Merged\*.*" "$(TargetDir)"


Of course to use it you have to point script to ILMerge executable, your strong name file and add assemblies you’ve used.