A Practical Guide to SharePoint 2013

A Practical Guide to SharePoint 2013
A Practical Guide to SharePoint 2013 - Book by Saifullah Shafiq

Monday, September 5, 2011

Programmatically waiting on SharePoint Solutions to deploy(Via Keith Richie)

Extract from the original post “I recently had the need to deploy multiple solutions via the object model, but of course had to wait for each solution to successfully deploy before moving to the next, etc. Another requirement is that I needed a common code base that would work on either SharePoint 2007 or SharePoint 2010. And of course, needed to work for a single server installation or a farm.

There are multiple posts out there about interfacing with and examining the running jobs on all servers via the timer service etc., but none of them seemed to work perfectly for me.

One would immediately think just to check SPSolution.Deployed and wait for it to be true before moving on to the next.

In my testing, this works great on SharePoint 2010 in my test environments, but not so well on SharePoint 2007.

For me, I found that not only did I need to check SPSolution.Deployed, but also check SPSolution.JobExists immediately afterwards. I couldn’t just rely on SPSolution.JobExists, because at times it would be false right after adding the solution (Perhaps because the Job had yet to actually start).

So for me, it was best to first wait until SPSolution.Deployed was true, then wait for SPSolution.JobExists to be false.

This seemed like the simplest method for ensuring the solution was deployed and complete before moving on.”

For complete post visit Keith’s blog here.