Improving the automated package installs

Last week I looked at some simple PowerShell script to automate installing packages into Sitecore instances. Having spent a bit of time testing this process, I found a couple of useful tips for speeding it up:

Hey reader!
After many years, I’ve finally decided to start moving off WordPress and onto a blog I host myself. This post is now available at ““. Eventually this version will be retired so please update links on any sites you control, to avoid 404s in the future.

Start Sitecore before you try to install packages

The first request to a Sitecore site (after it’s been installed) usually takes a while as everything has to be started up and loaded into memory. Hence it’s possible that the time for this to happen, plus install a package might cause a timeout.

So it makes sense to fire of some simple requests to the Sitecore site before you try to install packages:

function Start-Sitecore(){
    $siteName = Get-ConfigParam "InstanceName"
    $url = "http://$siteName/"

    Write-Host "Starting Sitecore..."

    $result = Invoke-WebRequest -Uri $url -TimeoutSec 0

    if($result.StatusCode -ne 200){
        throw "Sitecore failed to start at url $url"
    } else { 
        Write-Host "Public site started..."

    $url = $url + "sitecore/"

    $result = Invoke-WebRequest -Uri $url -TimeoutSec 0

    if($result.StatusCode -ne 200){
        throw "Sitecore UI failed to start at url $url"
    } else { 
        Write-Host "Admin site started..."

This bit of code makes a request to the instance name (to load the public site) and then to the /sitecore folder to initialise the admin interface.

Disable search indexing while installing packages

Another trick which can be helpful when installing large packages is to turn off Sitecore’s automatic indexing of new items while the package installs. There’s a helpful write up of how you can do this, and make use of it in the Sitecore UI here, but we just need the underlying configuration setting for a patch:

<configuration xmlns:patch="">
        <setting name="Indexing.UpdateInterval">
          <patch:attribute name="value">00:00:00</patch:attribute>

We can add a reference to a file containing this patch to the config for the install:


    <param name="IndexPatchFile">.\files\StopLucene.config</param>


And then disabling indexing is as simple as copying that patch file to the right folder:

function Disable-Indexing(){
    Write-Host "Disabling indexing..."

    $siteName = Get-ConfigParam "InstanceName"
    $sitecorePatchFolder = "C:\Inetpub\wwwroot\$($siteName)\Website\App_Config\Include"

    $patchFilePath = Get-ConfigParam "IndexPatchFile"

    Copy-Item $patchFilePath $sitecorePatchFolder

This function can be run immediately before starting Sitecore and then installing the package files. And once the packages are installed, the automatic indexing can be re-enabled by simply deleting the patch file again:

function Enable-Indexing(){
    Write-Host "Re-enabling indexing..."
    $siteName = Get-ConfigParam "InstanceName"
    $sitecorePatchFolder = "C:\Inetpub\wwwroot\$($siteName)\Website\App_Config\Include"

    $patchFilePath = Get-ConfigParam "IndexPatchFile"
    $patchFile = (Split-Path -Path $patchFilePath -Leaf)

    $file = Join-Path $sitecorePatchFolder $patchFile

    Remove-Item $file

One thought on “Improving the automated package installs

  1. Pingback: Enabling automated index rebuilds | Jeremy Davis

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.