With the release of TDS 5.5, deployments now support post-deploy actions with a few out of the box options. However, you can even add your own custom actions into the flow. With a little help from Hedgehog Sitecore MVP Sean Holmesby (Thanks Sean!), I was able to get this working using the following six easy steps.
Step One: Class project
Create a new project to hold your Post Deployment actions. (e.g. MyProject.PostDeploySteps)
Step Two: Reference processor
In the MyProject.PostDeploySteps project, add a reference to the Hedgehog Package Install Processor (HedgehogDevelopment.SitecoreProject.PackageInstallPostProcessor)
MAKE SURE THIS IS THE 5.5 DLL! This will get you access to the interfaces you need to implement.
Step Three: Custom Deploy Action Class
In the MyProject.PostDeploySteps project, create a class for your custom deploy step. It must implement IPostDeployAction
using System;
using System.Collections.Generic;
using System.Linq;
using HedgehogDevelopment.SitecoreProject.PackageInstallPostProcessor.Contracts;
namespace MyProject.PostDeploySteps
{
public class MyDeployAction: IPostDeployAction
{
public void RunPostDeployAction(System.Xml.Linq.XDocument deployedItems, IPostDeployActionHost host, string parameter)
{
throw new NotImplementedException();
}
}
}
Step Four: Implementation
Add the implementation for your custom deploy step. You might want to just write to the log right now to test it out.
host.LogMessage("Doing stuff: {0}", parameter);
Step Five: Add to the project
Edit your SCPROJ file manually with your favourite text editor. Add the following block to the file contents:
<ItemGroup Condition=" '$(Configuration)' == 'Release' ">
<PostDeployAction Include="MyProject.PostDeploySteps.MyDeployAction, MyProject.PostDeploySteps">
<Parameter>MyParameterForMyDeployStep</Parameter>
<Order>0</Order>
</PostDeployAction>
</ItemGroup>
Step Six: Reload
Reload your project in Visual Studio and your post deploy step will show!
Important note:
You need to make sure the DLL that contains your processor gets included in your build, otherwise it won’t be able to run. A good way to do this is to add a reference to your deploy steps project on your Website project that is being published for deployments.
Less important note:
Even if you decorate your class with [Description] details, it will not display in the TDS dialog, so make sure your class name is descriptive!
A note for the trivia books:
If you set the configuration condition to have it apply to all, or everything but Debug, it will execute on deployments, but does not display in the plugin. This seems to be a bug in the current version as of writing (i.e. 5.5.0.6).
UPDATE (2016-05-08): This issue has been corrected in 5.5.0.9.
1 Comment