[Important News!]
I’ve kicked off a new project/band where I’m creating music with a heavier techno/metal sound called binarywaste. You should check it out by clicking right here!
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.
So here’s a bit of a code snippet to show you basically what I’m doing. The following code assumes you have no specific web application you’re deploying to
SPSolution solution = SPFarm.Local.Solutions.Add("pathtomysolution.wsp"); solution.Deploy(DateTime.Now, true, true); bool deployed = solution.Deployed; while (!deployed) { Thread.Sleep(1000); deployed = solution.Deployed; } bool jobexists = solution.JobExists; while (jobexists) { Thread.Sleep(1000); jobexists = solution.JobExists; }
With this, I don’t have to muck around with poking at the timer job service on every single server in the farm etc.
I’m curious how this might work in your environments and hope this helps!
– Keith
HI Keith, can you tell me where to “put” this colde in my solution?
I am deploying from visual studio 2013 to the local SP dev server and getting the dreaded Error occurred in deployment step ‘Activate Features’: Feature with Id ” is not installed in this farm, and cannot be added to this scope.
I’m wondering if it’s a timing thing or if I have the scope incorrect.
Farm solution, scoped to web and has a vaild siteURL (sub site)
Because I can’t activate on deploy means (I think?) that I am unable to debug my code in VS.
I’m having to deploy without activation, go to the site, activate the feature, see if the bug is fixed and, if not, go back to step 1.
Jay, did you ever find a solution to your issue? I’m going through a very similar one right now. Any info would be deeply appreciated!
Keith, where do I place this in my .bat file?