Sean Holmesby

.NET and Sitecore Developer


TDS Post Deploy Step – Rebuild Link Database Script

This post shows how I created a custom TDS Post Deploy Step to rebuild the Link Database after my deployment in the Launch Sitecore TDS solution.

Hedgehog are currently asking for community contributions to the Post Deploy Step repository, so we can all benefit from each other’s work.

Got an idea for a Post Deploy Step? Let us know.
Getting started is super easy.

My Custom Post Deploy Step:

Problem: When links are made between Sitecore items (for example, through the use of internal links, and reference fields), Sitecore will store those relationships in the Links Database. The Links Database provides quick access to these bidirectional relationships between items, allowing Sitecore to quickly retrieve related items. It’s generally a good idea to rebuild the links database from time to time, especially when working with reference fields or developing features that rely upon it directly.

Solution: This post build step will programmatically rebuild your entire link database after the deployment is successful.

Installation: Install the post build step using the instructions. Pass in one or more database names in the form of a comma separated list. Links are stored in the ‘core’ database by default, however, if your requirements are different, you can pass multiple values like so: core,master,web. This post build step can take a while to run so you’ll need to make sure TDS accounts for that by increasing the timeout interval.

using HedgehogDevelopment.SitecoreProject.PackageInstallPostProcessor.Contracts;
using Sitecore.Data;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;
namespace HedgehogDevelopment.TDS.CustomExtensions.PostBuildProcessors
    public class RebuildLinkDatabase : IPostDeployAction
        public void RunPostDeployAction(XDocument deployedItems, IPostDeployActionHost host, string parameter)
            var databases = this.GetDatabases(parameter);
            foreach (string databaseName in databases)
                Database database = Sitecore.Data.Database.GetDatabase(databaseName.Trim());
                if (database == null)
                    host.LogMessage("Database with the name '{0}' in null", databaseName);
        private string[] GetDatabases(string parameters)
            if (string.IsNullOrEmpty(parameters))
                throw new System.InvalidOperationException("Please specify comma separated databases in the parameter setting.");
            return parameters.Split(new char[]
            }, System.StringSplitOptions.RemoveEmptyEntries);

Leave a Reply

Your email address will not be published. Required fields are marked *