8

I'm trying to optimize package installation process and looking for a solution to create a hash of Sitecore update package that will not take into account attributes of the files added to this package. I do not care about modification dates and file permissions etc. Only content.

Hash should be based purely on the content of this package, but the problem is that it contains multiple archives in it. Is there any "nice" way to get this hash?

PowerShell Get-FileHash could get a hash of one file content, but not in case of archived folder.

  • Are you considering using PowerShell to scan through all of the items and files outlined in the project file, hashing each of them then creating a single combined hash? – Michael West Oct 12 '16 at 20:07
  • Project file won't work as at the moment I need to install update package I do not have access to the project. In order to go over all files, I need to unpack the update package and then package.zip in it and merge hashes. This doesn't look nice to me. – Alex Smagin Oct 12 '16 at 22:05
  • The package contains a project file in it which should match the project.xml used to create it; although not sure if it's identical. SPE has an anti-package script that interrogates the package to create the rollback. You could then read each stream and generate the hash. Not a simple solution though. – Michael West Oct 12 '16 at 22:08
  • 1
    You can override the Generate Package button action to compute this hash when *.zip is being generated. (refer to .net Reflector or DotPeek) after that you can append this hash to your file name, or maybe generate a separate .txt in the same folder. – Andrey Bobrov Oct 26 '16 at 6:57
  • Is this question about content/module packages, or is it about update packages? Please clarify and update question tags. – Dmytro Shevchenko Oct 30 '16 at 20:22
1

Im doing this to optimize CI/CD deployments of TDS packages. I wanted to avoid re-deployment of this packages every time, when I really knew there was no change on the content/templates etc.

To achieve what you want you need to create a Powershell script (or on any other scripting language) that generates CRC32 hash number based on the content of the .update package.

The only tool that I found that was able to get me the hash based on content and without considering the file attributes like created date, etc, was 7zip.

Like in this example I'm running the command with a Sample.update file: enter image description here

Now every time you build your update packages if you get the same hash you know that the package hasn't change. So every time you make a 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 for deployment.

I added more details and a sample script on my blog: https://www.raulruizstack.com/2019/01/30/deployments-of-sitecore-packages-that-didnt-change-with-crc32/

  • Nice approach :) I've actually abandoned TDS for quite a while now and working with unicorn – Alex Smagin Feb 2 at 15:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.