Let's Share

My personal place to share knowledge about Sitecore, Powershell, Amazon Web Services and .NET

How to work with two versions of Sitecore Installation Framework

posted by Robert Senktas   | 2018-12-28

two-sif-versions-installed With Sitecore 9.1 a new SIF was released. SIF 2.0 is not compatible with the previous version of Sitecore. If you want to use Sitecore 9.1 and Sitecore 9.0.x in one environment, you have to install two SIF modules 1.2.1 and 2.0.0. Be default cmdlet Install-Module installs the newest version of the module. For Sitecore 9.1 and later we need the latest version of SIF, it means that we can use a standard module installation approach, shown below:

#region "SitecoreInstallFramework for Sitecore 9.1 and later"
if( (Get-Module -Name SitecoreInstallFramework -ListAvailable) -eq $null )
{
    #If install-module is not available check https://www.microsoft.com/en-us/download/details.aspx?id=49186
    Install-Module SitecoreInstallFramework -Scope AllUsers -Repository SitecoreGallery
}

Install previous module version

For Sitecore 9.0.x we need SIF with version 1.2.1, and we have to add more parameters to install specified module version. To choose version we have a parameter -RequiredVersion. To allow existence two different modules versions, we have to use parameter -AllowClobber. The full code snippet is shown on an image below:

#region "SitecoreInstallFramework for Sitecore 9.0.x"
$sifModule = Get-Module -Name SitecoreInstallFramework -ListAvailable
if(  $sifModule -eq $null -or $sifModule.Version -ne '1.2.1'  )
{
    #If install-module is not available check https://www.microsoft.com/en-us/download/details.aspx?id=49186
    Install-Module SitecoreInstallFramework -Scope AllUsers -Repository SitecoreGallery -RequiredVersion 1.2.1 -AllowClobber
}
#endregion

How to choose proper module version?

When we have two different versions of SIF installed in one environment, we need a way to choose which one version we want to use during the Sitecore installation process. We can quickly implement module version selector with a #required statement. More about how to prevents a script from running without the required elements, you can read in my post. To choose module version just put this at the beginning of your Sitecore installation script.

#requires -modules @{ ModuleName="SitecoreInstallFramework"; ModuleVersion="1.2.1" } 
#requires -modules @{ ModuleName="SitecoreInstallFramework"; ModuleVersion="2.0.0" } 

Where to find more examples?

If you are looking for more examples of how to improve Sitecore installation process, please check Sitecore Installation Extensions.

Powershell Sitecore SIF Sitecore 9
This is a personal blog. All opinions here are my own opinions and do not represent my employer’s view in anyway.

Sitecore Automation Module