A better CustomTargets.ps1/eventing proposal

Apr 22, 2013 at 1:45 PM
Hi team,

I was playing with CustomTargets.ps1 and events such as "BeforeUpdate/BeforeUpdate" and the rest. Quite smooth experience, great!

However, here are some ideas I thought of:

It turns out that SPSD runs pair "BeforeUpdate/AfterUpdate" for the "Update.bat" and "BeforeDeploy/AfterDeploy" for the "Deploy.bat". So, it is quite tricky to write/attach custom PS logic for "every deployment" despite the deployment type (deploy/upgrade/retract).

For example, I utilize Hyper-V/SCVMM to manage test VMs. Before every upgrade/deployment, I need to revert those VMs to previous checkpoint/snapshot. Well, right now I could utilize BeforeUpdate/BeforeUpdate/BeforeDeploy/AfterDeploy events. However, a "more global" event would be really cool option.

Another one thing has to do with "Checking System Preconditions". That check is run before any events. So, there is no chance (I can't see it right now) to run our own PS logic before "Checking System Preconditions". I suppose it is better to run VM reverting before system check (I surely can turn it off, but ensuring "services for deployment SPTimer/SPAdmin" and so on is a cool thing! :)

Then, SCVMM snapins should be loaded within "Load Addins" step (as I try to follow SPDS way to do things). I see StartUp/LoadSharePointPS function, but no entry point to attach to.

Also, one more moment about $vars variable for events. Seems it hasn't been implemented yet. There is no way to stop/skip deployment process via $vars variable BeforeUpdate/BeforeDeploy action?

Finally, putting all that together:
  • would be nice to have clear, clarified event flow for the current SPSD release
  • would be really cool to have additional "global" events which don't depend on "Update/Deploy/Retract" flows
  • would be just awesome to have events for steps such as "LoadAddins", "Checking System Preconditions" and "Warning up" (not sure about other steps yet )
  • $vars variable is a good place to control the process flow to skip/stop whole deployment process. Would be nice to see the future's implementation and ideas around that.
Apr 22, 2013 at 3:06 PM
Edited Apr 22, 2013 at 3:43 PM
Wow, that is quite some feedback! Thanks for all your ideas!

Need to get my head around these first ;-)

Adding more targets would be of course no big deal, but also increases complexity.

How about the following suggestion:
  • Target: CustomPrerequisites which will run after adding the SharePoint and WebAdmin Snapins. This allows to add your custom addins or other prequisites to prepare the environment or do your SCVMM stuff.
  • Target: CustomPreconditions which will run after the the "Check Prerequisite Solutions" at the very end of the prereq check block. If this function returns false, then the script will not continue. If it returns true or nothing it assumes everythings is good to go.
  • Target: Initialize which runs after succesfully checking the precondintions before any deploy/update/rectract action is started. This will allow you to do anything to the running SharePoint environment in any case.
  • Target: Finalize which runs at the very end of the script before the summary is shown
  • Provide a documentation about the flow of the process and where the custom targets fit in.
Would that make sense based on your requirements?

What I am not sure about:
  • Actions/Warming up: What would you think of putting in there? Would the Finalize target be sufficient for your purposes? If not could describe the scenario a bit more?
  • $vars is really meant to only keep the variables defined in the XML available. It is not planed to use it to control the process. So I would rather introduce a different logic to "control the process flow". But I need to think about that little more. Drop in your thoughts if you like.
Apr 22, 2013 at 11:37 PM
This looks good. Thanks for the fast response.
Well, I'll play more with SPSD. Need some time to learn more and think about all these ideas. I'll come back later.
Apr 23, 2013 at 2:54 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.