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.

Wednesday, July 22, 2015

HowTo: Avoid simultaneous execution of 2 instances of same workflow for a record

Let’s imagine that you (as a consultant) use waiting workflows (booo, I know that waiting workflows are evil). But let’s imagine and you have a field on a record that is responsible for datetime till when workflow has to wait to proceed. Obviously that change of a datetime field should lead to change of workflow “waiting to proceed” time. But you can’t apply this change to workflow that is triggered already. So to complete the task you have to kill existing instance of a workflow and run new. This article describes custom workflow activity that does the trick.