Sitecore Upgrade Assist Visual Studio Extension

Posted on

Intro

After upgrading multiple Sitecore solutions, I noticed there are whole a lot of awfully slow tasks that can be automate. Hence, Sitecore Upgrade Assist is created to simplify important tasks including:

  1. Upgrading .NetFramework to the one matching the new Sitecore version
  2. Upgrade Nuget packages to match the new .NetFramework and Sitecore.
  3. Upgrade Sitecore packages.
  4. Upgrade GlassMapper.

The above tasks took me long hours to complete as I had to first discover what version of the Nuget package matches Sitecore and secondly go through each package one by one and upgrade them. I don’t think anyone should go through that pain again. Sitecore Upgrade Assist is an open source Visual Studio Extension for a better Sitecore upgrade experience.

Download the tool from Visual Studio Market place or check out the code on Github.

Sitecore Upgrade Assist Visual Studio Extension

The Sitecore Upgrade Assist is a toolbox every developer needs to upgrade a Sitecore solution. For starter, it consolidates all the Nuget package required for a Sitecore Version in a modifiable xml file.

Config File

This config file is what I have used to upgrade a Sitecore solution to version 9.3.0 and can be extended to update any common packages specific to your solution. These config files are stored in Visual Studio Extension folder for now and in Later versions, I will move them to a more accessible location.

 

Upgrade Framework

This feature is originally provided by TargetFrameworkMigrator and it is the first step for a Sitecore upgrade. To use this feature simply select all projects and click on Upgrade Framework. Note that the projects will not be automatically saved after upgrade. You should save all and build the project after this step. If everything is good and the build is successful, commit changes and move on the next step.

Package Upgrade

This feature uses NuGet.VisualStudio to upgrade all the necessary Nuget packages including Sitecore, Microsoft and other dependencies. It will first get the list of installed packages within the selected projects, check if the config file has specified a new version for the package ID and then install the given version. If the package does not have an equivalent within the config file, it will reinstall the same version for the new .NetFramework.

Microsoft packages

Since most of the Sitecore packages depend on MS packages, the tool starts first with them. Note that for this step, you must have a Nuget source named nuget.org in your solution and it must be enabled. Additionally, the installation is done with ignore dependency option to speedup the process and avoid conflicts.

Sitecore packages

After upgrading the MS packages, the tool moves on to upgrading Sitecore Nuget packages. They are detected by their prefix. Every package starting with Sitecore. will be considered and the corresponding version is set in SitecorePkgVersion node within the config file.

The package source used for Sitecore packages should be named Sitecore or Sitecore V2 and be enabled.

The tool is smart enough to understand that Sitecore packages before 9.1.0 had .NoReference suffix added to them. It will remove that package and install the equivalent for the new version.

Other dependencies

The final step for this feature is to upgrade all other packages except GlassMapper. This is where dependencies like Newtonsoft.Json, xunit, or System.xx are upgraded. Additionally, if you add any of your custom packages to the config file, it will be also updated here.

Once you have executed this feature on all your projects, you should certainly clean and rebuild the solution. This is where all the incompatible code surface and you will be spending a lot of time resolving those. This tool thrives to provide more assistance for this step.

Notes for upgrading packages

  • The package upgrade step can be a lengthy and expensive considering the number of packages and projects included.
  • Intern connection is important here.
  • If your solution is considerably large (more than 50 projects), it’s better to upgrade the solution in batches, build the solution regularly and start with foundation level first.
  • Disable any Package Source not needed during the process.

Glass Upgrade

The final step is to upgrade Glass Mapper if you are using it. I have separated this step as it can raise several errors during the build specially if you are upgrading from v4 to v5. For this step, the tool will prompt for the current package version. The version is what you see in the glass package id as highlighted in the screenshot below.

If there is no version within the package id, select the first combobox option “Empty” and press ok.

The tool will use the selected version ID to identify and match the glass version and install the right package.

Results

Future Features

  • Refactor to glass V5 => Find all the calls to ISitecoreContext and replace it with a custom foundation class that internally uses MvcContext, RequestContext or WebFormsContext.
  • Migrate to PackageReferencing => Enables quick migration for all supported projects.
  • Config file for more Sitecore versions including Sitecore 10.0.0
  • Support for VS 2017.
  • More accessible config files.
  • Upgrading to AsyncPackage.

Call for collaboration

I have made the tool accessible in github and It would be great if you guys could help out for the development and adding more features. Any suggestions and feedbacks are also welcome. May the force be with you during the upgrade.

Tags: , ,


Leave a Reply

Your email address will not be published. Required fields are marked *