Exam Area: Content Area 2 – Installation, Operation & Configuration (20%)
Reference: https://docs.developers.optimizely.com/content-management-system/docs/installing-optimizely-net-5
https://api.nuget.org/v3/index.json (NuGet.org)
https://nuget.optimizely.com/feed/packages/ (Optimizely NuGet)
# Install Optimizely CMS templates
dotnet tool install EPiServer.Net.Cli --global --add-source https://nuget.optimizely.com/feed/packages/
# Verify installation
dotnet episerver --version
# 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
<!-- .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>
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();
{
"ConnectionStrings": {
"EPiServerDB": "Server=.;Database=MyCMSDb;Trusted_Connection=True;TrustServerCertificate=True"
},
"EPiServer": {
"CMS": {
"DefaultLanguage": "en"
}
},
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}
# 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
}
}
}
On the first run:
/episerver/cms to log indotnet episerver create-user --username admin --password Password123! --roles WebAdmins,WebEditors
<!-- module.config - in wwwroot/episerver/ -->
<?xml version="1.0" encoding="utf-8"?>
<module>
<assemblies>
<add assembly="MyOptimizelySite" />
</assemblies>
</module>
http://localhost:5000/episerver/cms → CMS Edit UI
http://localhost:5000/episerver/cms/admin → Admin Panel
https://nuget.optimizely.com/feed/packages/)EPiServer.CMS)app.MapContent())AddCmsAspNetUI() do? (Adds CMS Edit/Admin UI services)EPiServerDB in appsettings.json)