Pages

06 May, 2021

Sitecore Upgrade - Sitecore NuGet Package Upgrade using PowerShell

This blog is related to thSitecore codebase upgrade series.

Sitecore enabled package management system for the Sitecore packages from version 9.x. This has helped to avoid unnecessary and complicated reference management. In order to do .NET framework upgrade and Sitecore NuGet package upgrade, there are various ways as follows.
  1. Using NuGet Package Manager 
  2. Using PowerShell Package Manager Console
  3. NuGet CLI
  4. dotnet CLI
Certain Sitecore Helix solution may have 100s of projects so using NuGet Package Manager in Visual Studio may not be productive. As a programmer, you can leverage the PowerShell Package Manager Console to inspect each project and update the packages. 

Gary has written a script to update the Sitecore Packages and as he mentioned, it is easy to extend and tweak it as per our need. One of my requirement is to find the projects which are having Sitecore Packages and update all the packages to the target version in a single shot.  

The below script accepts the old package version and the new package version and finds all the projects having "Sitecore." packages and upgrades the packages to the target version along with dependencies. Save the gist file as nuget_Profile.ps1 in C:\Users\[user]\Documents\WindowsPowerShell folder and restart the Visual Studio for the PowerShell Package Manager console to pick up the profile scripts. 
  1. Finds all the projects with Sitecore packages
  2. Loop through each projects and updates the Sitecore Packages.
  3. If NoReference Package is installed, it finds the alternative package with NoReference and installs it. 
In the PowerShell Package Manager console, execute the method along with old and new package version as below. Please note script is defaulted to version 9.3.0 as old version and version 10.1.0 as the new version. 
UpdateSitecorePackagesForAllProjects -NewVersion 9.0.171219 -OldVersion 10.0.1



No comments:

Post a Comment

blockquote { margin: 0; } blockquote p { padding: 15px; background: #eee; border-radius: 5px; } blockquote p::before { content: '\201C'; } blockquote p::after { content: '\201D'; }