Incrementing the Umbraco Client Dependency version with Octopus Deploy

If you use Octopus deploy to deploy your Umbraco sites, you've probably forgotten to increment the Client Dependency version before building and deploying - which leads to old CSS and JavaScript being served.

Octopus Deploy allows you to run custom powershell scripts during the deployment life cycle - and the one below will set the client dependency version.

$Config = ".\config\ClientDependency.config";

If (Test-Path $Config) {

    $Cd = New-Object System.Xml.XmlDocument
$Cd.Load($Config)
    
$Rel = ($OctopusParameters['Octopus.Release.Number']);
    $Cd.clientDependency.version = $Rel.Replace(".", "");

    $Cd.Save($Config)
} 

If (Test-Path "bin\version.txt"){
Remove-Item "bin\version.txt"
}
"$($OctopusParameters['Octopus.Release.Number'])" | Out-File "bin\version.txt"

The script should be run post deployment. Rather than incrementing the client dependency version - it derives an integer from the octopus release version, so the client dependency version is distinct for each release.

If you need some help setting up Octopus deploy and Umbraco - get in touch with me, via my company website.

Comments

Leave a comment