We are all excited about Sitecore 10 and the direction the platform is taking towards .Net Core and Headless. However the task of updating your existing solution to conform to the new headless approach, might seem overwhelming.
Sitecore 10 Headless is now split to into two project types, Platform and Rendering Host.
Platform is specific to Sitecore (CM), and only configurations and code directly related to either extending or configuring Sitecore should exist here.
Rendering (Rendering Host) is specific to the Application and should contain all code and configurations required for the application to run.
Following Helix conventions you’ll now most likely need to have two projects (.csproj) per module. See Hero example below;
- Helixbase.Feature.Hero.Platform – .Net Framework
- Helixbase.Feature.Hero.Rendering – .Net Core
Making the Move to Headless (NetCore)
Updating an existing Helix MVC solution the new Headless approach is a time consuming task. I have written a Powershell script to take some of the pain away.
Simply run the script within a Helixbase solution from the ./tools directory and it will update your solution ready for Headless development.
- Update the variable in the script $solutionName to match you solution name, if its not equal to Helixbase.
- Close the solution
- Execute Powershell script with elevated privileges (Admin)
The script will perform the following tasks:
- Converts all existing Helix modules into Platform relative projects, updating the Framework reference to .Net Framework 4.8
- Creates a new Rendering .Net Core project for each Module (Includes nuget packages for Rendering Engine and Layout Service)
- Updates any (HPP) Helix Publishing Pipeline projects and sets them to only work with Platform modules.
- Creates a new Rendering Host .Net Core web app along side the HPP site.
- Updates all namespace reference to meet the new naming conventions of SolutionName.Layer.Module.Platform and SolutionName.Layer.Module.Rendering
Once complete open the solution and you’ll see changes to each module. See below
You now have a solution that is ready to start being used for Headless development. All of your existing code is in the Platform (CM) project, you will now need to decouple this, moving the application over to the Relevant Rendering project.
The rendering host project will need configuring and setting up as the script currently only generates a vanilla .NetCore Web App. You can use Sitecores documentation as guide for this here or check Helixbase Headless for an example. Helixbase headless is currently work in progress but I intend to have the Rendering Host available shortly.
Get the scrip here