Technology Content

Sitecore platform content

SIF Masters: Building a Universal 10x Installer

One specific goal for me was to create a self-contained installer for Sitecore 10x. Ideally, once 10.3 drops, I could pass a parameterized set of data to a PS1. This parameter would allow to select between 10.1 - 10.3, fly past the normal DacPac, WebDeploy, Solr, and Marketing Engine issues… and net me a working instance. This post looks at some key considerations for the task.

Automate Bit Selection for X64 and X86 Servers

Many folks don't consider it, but the bit selection on a server means something. To that point, one main element that we consider is the WebDeploy prerequisite. In the example, a simple PS switch is used to pull in WebDeploy_amd64_en-US.msi or WebDeploy_x86_en-US.msi.

switch ($scxDepBit) {
   '64' {
       
       $scxDepWebDeploy = "WebDeploy_amd64_en-US.msi"
   }
   '86' {
      
       $scxDepWebDeploy = "WebDeploy_x86_en-US.msi"    
   }
}
 

SOLR and Dot Net Hosting

One difficulty in a universal installer is SOLR and Dote Net Hosting. 10.1 and 10.2 use different versions. To manage this, we utilized PS switching based on a version parameter.

switch ($scxVersion) {
   '10.1' {
       $scxDepDotNetHostingVersion = 'dotnet-hosting-2.1.23-win.exe'
       $scXSolrRoot = (Join-Path $PSScriptRoot Solr-8.4.0\)
   }
   '10.2' {
       $scxDepDotNetHostingVersion = 'dotnet-hosting-3.1.16-win.exe'
       $scXSolrRoot = (Join-Path $PSScriptRoot Solr-8.8.2\)    
   }
}

Automate Your Registry Changes

A good number of issues can arise from basic registry failures. In many cases, there are some well known fixes to SIF installation failures for which the resolution can be automated. Luckily in PS, you can utilize Get-Item and New-Item to check and create/update registry values as need.

function ManageRegistry([string]$registryPath, [string]$registryKey, [string]$registryValue, [string]$action = 'install') {

   $registryFqn = "$registryPath\$registryKey"

   if ($action.ToLower() -eq 'install') {

       $_registry = (Get-ItemProperty $registryPath).PSObject.Properties.Name -Contains $registryKey


       if (($_registry -eq $null) -or ($_registry.Length -eq 0)) {
           ManageConsoleOutput -message "Deploying registry: $registryFqn."
           New-ItemProperty $registryPath -Name $registryKey -Value $registryValue
       }
       else {
           ManageConsoleOutput -message "Registry already deployed: $registryFqn."
       }
       
       Get-ItemProperty -Path $registryPath -Name $registryKey
   }

   if ($action.ToLower() -eq 'delete') { 
       Remove-ItemProperty $registryPath -Name $registryKey
       
   }

}