
Avoiding deployments of Sitecore ‘.update’ packages that didn’t change
When we have a Sitecore TDS projects that generates .update packages with content items, its a good idea to automate the deployment process. But depending on the size of this packages this process could take several minutes to complete. To reduce the time I have to calculate the CRC32 of the packages to make sure I’m only deploying packages that change between one release to the next one.
For this I created a Powershell script (could be any scripting language) that generates the hash based on the content of the .update package.
One tool that was able to return me the CRC32 hash based on content and without considering the file attributes (created date, etc) was 7zip.

Now lets go step by step in what needs to be done, and how to do the comparison of the CRC32:
- On your build server or whenever you generate the .update packages make sure you have 7zip standalone executable around.
- After you have the packages generated collect them on a single folder, and do an enumeration to get the file paths in a variable. For simplicity lets say is only one file called Sample.update, and the path is stored on $filePath.
- Run on every file the following 7zip command with
h
parameter and save the output:$outputFromCommand = &7z.exe h $filePath
- From the captured output extract the CRC value like:
$hashValue = (($outputFromCommand -match "CRC32 for data:")[0] | Select-String -Pattern "[^\s]{8}").Matches[0].Value
- Rename the file and append the CRC value to it, like
Sample_CRC_39EB97BF.update
.
Every time you build your update packages if you get the same file name (same hash) you know that the package hasn’t change. So on each release store the files that you deployed somewhere, and on any subsequent release before deploying compare the files. If there is a difference, you know that you have candidates to be deployed next, or if not, skip the process.
I have this step automated with another Powershell that does the comparison, and keeps a backup of files deployed. But there are many ways you can keep track of what changed.
For clarity, this is a small script with part of the process:
$exec = "C:\Program Files\7-Zip\7z.exe"
$srcPath = ".";
$items = Get-ChildItem -Path $srcPath -Filter "*.update" -Recurse -ErrorAction SilentlyContinue
foreach($item in $items)
{
$outputFromCommand = &$exec h $item.FullName;
$hash = (($outputFromCommand -match "CRC32 for data:")[0] | Select-String -Pattern "[^\s]{8}").Matches[0].Value
Write-Host "The hash is $hash"
$newFileName = $item.BaseName + "_HASH_" + $hash + ".update"
Write-Host "Renaming to $newFileName"
Rename-Item ($item.Name) $newFileName -Force
}

Having the deployment candidates I can use something like Sitecore.Ship to deploy the packages. For more info on this you can read my other post: https://www.raulruizstack.com/2019/01/08/sitecore-ship-installation-and-configuration-to-support-sitecore-update-package-deployments-like-tds-in-a-ci-cd-pipeline/