⚙️ Installation & Configuration
Installation
📖 Docs

Installing Optimizely CMS 12 (ASP.NET Core)

Exam Area: Content Area 2 – Installation, Operation & Configuration (20%)
Reference: https://docs.developers.optimizely.com/content-management-system/docs/installing-optimizely-net-5


1. Prerequisites

System Requirements:

NuGet Sources:

https://api.nuget.org/v3/index.json  (NuGet.org)
https://nuget.optimizely.com/feed/packages/  (Optimizely NuGet)

2. Installing CLI Templates

# Install Optimizely CMS templates
dotnet tool install EPiServer.Net.Cli --global --add-source https://nuget.optimizely.com/feed/packages/

# Verify installation
dotnet episerver --version

3. Creating a New Project

# Create a project with the Alloy template (demo site)
dotnet new epi-alloy-mvc --name MyAlloySite

# Create a blank CMS project
dotnet new epi-cms-empty --name MyBlankSite

# Create a project with database setup
dotnet new epi-alloy-mvc --name MySite --output ./MySite
cd MySite

# Create the database
dotnet episerver database create

4. Package References

<!-- .csproj -->
<Project Sdk="Microsoft.NET.Sdk.Web">
  <PropertyGroup>
    <TargetFramework>net6.0</TargetFramework>
  </PropertyGroup>
  
  <ItemGroup>
    <!-- Core CMS -->
    <PackageReference Include="EPiServer.CMS" Version="12.*" />
    
    <!-- UI for Edit/Admin -->
    <PackageReference Include="EPiServer.CMS.UI" Version="12.*" />
    
    <!-- TinyMCE editor -->
    <PackageReference Include="EPiServer.CMS.TinyMce" Version="*" />
    
    <!-- SQL Server support -->
    <PackageReference Include="EPiServer.CMS.UI.AspNetIdentity" Version="*" />
  </ItemGroup>
</Project>

5. Program.cs Configuration

using EPiServer.Cms.Shell;
using EPiServer.Cms.UI.AspNetIdentity;
using EPiServer.ServiceLocation;
using EPiServer.Web.Routing;
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;

var builder = WebApplication.CreateBuilder(args);

// Add CMS services
builder.Services
    .AddCmsAspNetUI()
    .AddCms()
    .AddEmbeddedLocalization<Program>();

// Add ASP.NET Identity
builder.Services.AddCmsAspNetIdentity<ApplicationUser>();

// Add MVC
builder.Services.AddControllersWithViews();

var app = builder.Build();

if (!app.Environment.IsDevelopment())
{
    app.UseExceptionHandler("/Error");
    app.UseHsts();
}

app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseRouting();

app.UseAuthentication();
app.UseAuthorization();

app.MapControllerRoute(name: "default", pattern: "{controller}/{action}/{id?}");
app.MapContent();  // CMS content routing

app.Run();

6. appsettings.json

{
  "ConnectionStrings": {
    "EPiServerDB": "Server=.;Database=MyCMSDb;Trusted_Connection=True;TrustServerCertificate=True"
  },
  "EPiServer": {
    "CMS": {
      "DefaultLanguage": "en"
    }
  },
  "Logging": {
    "LogLevel": {
      "Default": "Information",
      "Microsoft.AspNetCore": "Warning"
    }
  }
}

7. Database Setup

# Create database from CLI
dotnet episerver database create

# Or use code:
# The database is auto-created on first run if AutoUpdateDatabaseSchema = true
{
  "EPiServer": {
    "Framework": {
      "AutoUpdateDatabaseSchema": true
    }
  }
}

8. First Run

On the first run:

  1. The database is automatically created/updated
  2. Navigate to /episerver/cms to log in
  3. Create an admin user (if one does not exist)

Creating an Admin User:

dotnet episerver create-user --username admin --password Password123! --roles WebAdmins,WebEditors

9. Module Config Setup

<!-- module.config - in wwwroot/episerver/ -->
<?xml version="1.0" encoding="utf-8"?>
<module>
  <assemblies>
    <add assembly="MyOptimizelySite" />
  </assemblies>
</module>

10. Verifying the Installation

http://localhost:5000/episerver/cms    → CMS Edit UI
http://localhost:5000/episerver/cms/admin  → Admin Panel

Review Questions

  1. What is the Optimizely NuGet feed URL? (https://nuget.optimizely.com/feed/packages/)
  2. What is the primary package for installing CMS? (EPiServer.CMS)
  3. Which method in Program.cs enables CMS routing? (app.MapContent())
  4. What does AddCmsAspNetUI() do? (Adds CMS Edit/Admin UI services)
  5. Where is the database configured? (Connection string EPiServerDB in appsettings.json)