Wednesday, December 3, 2008

Expediting Plug-In Development Using VS Pre/Post Build Events


No doubt, CRM 4.0s new plug-in engine is a giant leap compared to the callout facility that was available on the 3.0 version.
However, a few things still hinder the development process. One of which is the fact that you need to reset the Internet information services (IIS) and copy your project files to the assembly bin folder each time you compile your code.

In order to overcome and automate the process you can add Pre and/or Post Build events to you plug-in project.
Build event are no more then command line instructions you need to run before and/or after you project builds.

The nice thing about Post events is that you can set them to run only if the build is successful. Which means the iisreset won’t run and the files won’t be copied unless the build is complete. Following are the Post build command instruction I add to every plug-in project we build.



1.Open the Build Events Property Page: The Build events are located on the Project Properties page under the build events Tab.
2.Add the following commands to the Post Build Event (make sure you run the command only on successful build)
Resets Internet information Services

call iisreset

Copy the *.dll file to the assembly bin folder.

xcopy "$(TargetPath)" "C:\[CRM INSTALL FOLDER]\Server\bin\assembly" /i /d /y

Copy the *.pdb file to the assembly bin folder

xcopy "$(TargetDir)$(TargetName).pdb" "C:\[CRM INSTALL FOLDER]\Server\bin\assembly" /i /d /y


That’s it.

2 comments:

Greg said...

I prefer to recycle the application pool rather than the extra time required with a full-blown 'iisreset':
cscript c:\windows\system32\iisapp.vbs /a "CRMAppPool" /r

Gouse said...

Great insights! Leveraging VS Pre/Post Build Events is a smart way to streamline plug-in development and improve efficiency. Thanks for sharing
Digital Marketing Course In Hyderabad

Digital Marketing Course In Ameerpet