Mandalorian.Sitecore.NetCore

This repo is an example/demo of a Sitecore .NET Core Rendering SDK. I presented this at the London Sitecore User Group & Pittsburgh SUG Recently: https://www.flux-digital.com/blog/building-components-in-sitecore-10-with-the-asp-net-rendering-sdk/.

It is a modified version of the Sitecore Getting Started Template provided by Sitecore as described here: https://doc.sitecore.com/developers/100/developer-tools/en/walkthrough--using-the-getting-started-template.html.

I've added Bootstrap 4 and some custom css, images, placeholders and components. Feel free to fork and test.

Alt text

About this Solution

This solution is designed to help developers learn and get started quickly with Sitecore Containers, the ASP.NET Core Rendering SDK, and Sitecore Content Serialization.

For simplicity, this solution does not implement Sitecore Helix conventions for solution architecture. As you begin building your Sitecore solution, you should review Sitecore Helix and the Sitecore Helix Examples for guidance on implementing a modular solution architecture.

Support

The template output as provided is supported by Sitecore. Once changed or amended, the solution becomes a custom implementation and is subject to limitations as defined in Sitecore's scope of support.

Prerequisites

  • .NET Core 3.1 SDK
  • .NET Framework 4.8 SDK
  • Visual Studio 2019
  • Docker for Windows, with Windows Containers enabled

See Sitecore Containers documentation for more information on system requirements.

What's Included

  • A docker-compose environment for a Sitecore XP0 topology with an ASP.NET Core rendering host.

    The included docker-compose.yml is a stock XP0 environment from the Sitecore Container Support Package. All changes/additions for this solution are included in the docker-compose.override.yml.

  • Serialized items for a one-page sample site (see src\Items.module.config).

  • An MSBuild project for an ASP.NET Core application which renders the site (see src\rendering).

  • An MSBuild project for deploying configuration and code into the Sitecore Content Management role. (see src\platform).

Running this Solution

  1. If your local IIS is listening on port 443, you'll need to stop it.

    This requires an elevated PowerShell or command prompt.

    iisreset /stop
    
  2. Before you can run the solution, you will need to prepare the following for the Sitecore container environment:

    • A valid/trusted wildcard certificate for *.myproject.localhost
    • Hosts file entries for myproject.localhost
    • Required environment variable values in .env for the Sitecore instance
      • (Can be done once, then checked into source control.)

    See Sitecore Containers documentation for more information on these preparation steps. The provided init.ps1 will take care of them, but you should review its contents before running.

    You must use an elevated/Administrator Windows PowerShell 5.1 prompt for this command, PowerShell 7 is not supported at this time.

    .\init.ps1 -InitEnv -LicenseXmlPath "C:\path\to\license.xml" -AdminPassword "DesiredAdminPassword"

    If you check your .env into source control, other developers can prepare a certificate and hosts file entries by simply running:

    .\init.ps1

    Out of the box, this example does not include .env in the .gitignore. Individual users may override values using process or system environment variables. This file does contain passwords that would provide access to the running containers in the developer's environment. If your Sitecore solution and/or its data are sensitive, you may want to exclude these from source control and provide another means of centrally configuring the information within.

  3. After completing this environment preparation, run the startup script from the solution root:

    .\up.ps1
  4. When prompted, log into Sitecore via your browser, and accept the device authorization.

  5. Wait for the startup script to open browser tabs for the rendered site and Sitecore Launchpad.

Using the Solution

  • A publish of the Platform project will update the running cm service.
  • The running rendering service uses dotnet watch and will recompile automatically for any changes you make. You can also run the Rendering project directly from Visual Studio.
  • Review README's found in the projects and throughout the solution for additional information.