Environment Setup
Outline
- Goal: Get a repeatable local setup (Windows/macOS) + understand DXP Cloud considerations
- Core stack: .NET SDK, IDE, SQL Server, Optimizely templates + CLI, NuGet feed
- macOS note: SQL Server typically runs via Docker
- DXP note: Secrets and services are managed; local dev integrates with them
Introduction
Setting up an efficient development environment is the cornerstone of successful Optimizely CMS 12 projects. This guide provides a highly technical, step-by-step walkthrough for developers to configure their local machines for Optimizely CMS 12 development on both Windows and macOS, and touches upon considerations for working with the Optimizely Digital Experience Platform (DXP) Cloud. This content is tailored for technical professionals who are new to the Optimizely PaaS CMS ecosystem.
Prerequisites (General for all OS)
Before diving into the setup, ensure you have the following core components installed:
- .NET SDK: Install the latest Long Term Support (LTS) version (e.g., .NET 8 SDK). This includes the .NET runtime and command-line interface (CLI) tools.
-
Integrated Development Environment (IDE):
- Windows: Visual Studio 2022 (Community Edition is free for individuals). Ensure you select the "ASP.NET and web development" and ".NET desktop development" workloads during installation.
- macOS: Visual Studio Code with the C# extension.
-
SQL Server: A local instance of SQL Server is required for the CMS database.
- Windows: SQL Server Express or Developer Edition, along with SQL Server Management Studio (SSMS).
- macOS: SQL Server for Docker (requires Docker Desktop) and a client like Azure Data Studio.
-
Optimizely NuGet Feed:
Ensure your NuGet configuration includes the official Optimizely feed. This is typically added automatically when
installing templates, but can be manually added via
nuget.configor your IDE's NuGet settings.https://nuget.optimizely.com/feed/packages.svc/
-
Optimizely Templates and CLI Tool:
These are essential for creating new Optimizely projects and managing CMS-specific tasks.
# Install Optimizely project templates dotnet new -i EPiServer.Templates # Install Optimizely CLI Tool dotnet tool install EPiServer.Net.Cli --global --add-source https://nuget.optimizely.com/feed/packages.svc/
Note: The latest versions of
EPiServer.Templatesand the CLI Tool require .NET 6 or higher.
Local Development Environment Setup: Windows
This section details the step-by-step process for setting up your Optimizely CMS 12 development environment on a Windows machine.
Step 1: Install .NET SDK and Visual Studio 2022
- Download and install the latest .NET LTS SDK.
- Download and install Visual Studio 2022. During installation, select the "ASP.NET and web development" and ".NET desktop development" workloads.
Step 2: Install and Configure SQL Server
- Download and install SQL Server Express or Developer Edition.
- During installation, ensure Mixed Mode Authentication is selected, and set a strong password for the
sa(System Administrator) account. - Install SQL Server Management Studio (SSMS) for database management.
- Verify SQL Server is running and accessible.
Step 3: Install Optimizely Templates and CLI Tool
Execute the commands from the "Prerequisites (General)" section in your command prompt or PowerShell:
dotnet new -i EPiServer.Templates
dotnet tool install EPiServer.Net.Cli --global --add-source https://nuget.optimizely.com/feed/packages.svc/
Step 4: Create a New Optimizely CMS 12 Project
Navigate to your desired development directory and create a new empty Optimizely CMS project using the CLI:
mkdir C:\Projects\MyOptimizelySite
cd C:\Projects\MyOptimizelySite
dotnet new epicmsempty --name MyOptimizelyCmsProject
cd MyOptimizelyCmsProject
This command creates a new solution and project structure for an empty CMS 12 site.
Step 5: Configure Hostname (Optional but Recommended for IIS)
For local development with a custom domain (e.g., mylocalcms.local), you need to modify your hosts file.
This is crucial if you plan to use IIS for local hosting.
- Open Notepad (or your preferred text editor) as an Administrator.
- Navigate to
C:\Windows\System32\drivers\etc\. - Open the
hostsfile. - Add the following line at the end of the file:
127.0.0.1 mylocalcms.local
Save and close the file.
Step 6: Set up IIS (Optional, for Production-like Local Testing)
While dotnet run uses Kestrel, hosting in IIS provides a more production-like environment.
- Enable IIS Features: Go to "Turn Windows features on or off" and enable "Internet Information Services" along with "ASP.NET 4.8" and "ASP.NET Core" components.
- Install .NET Core Hosting Bundle: Download and install the latest .NET Core Hosting Bundle for your .NET SDK version from the official .NET website. This installs the ASP.NET Core Module for IIS.
-
Create IIS Website:
- Open IIS Manager.
- Right-click on "Sites" -> "Add Website...".
-
Site name:
MyOptimizelyCmsProject -
Physical path: Point to the
publishdirectory afterdotnet publish. For now, your project root is fine. -
Host name:
mylocalcms.local(or your chosen hostname). - Click "OK".
-
Configure Application Pool:
- Go to "Application Pools".
- Find the pool named after your website.
- Right-click -> "Advanced Settings...".
- Set ".NET CLR Version" to "No Managed Code".
- Ensure "Identity" is "ApplicationPoolIdentity" or a custom user with permissions.
-
Set Folder Permissions: Grant read/write permissions to the IIS AppPool identity on your project folder,
especially
App_Dataandwwwroot.
Step 7: Create the CMS Database
Use the Optimizely CLI tool to create and initialize the CMS database. Replace -S, -U, and
-P with your SQL Server instance name, username, and password.
dotnet-episerver create-cms-database MyOptimizelyCmsProject.csproj -S .\SQLEXPRESS -U sa -P "YourStrongPassword"
This command creates the database, sets up the necessary tables, and populates initial data.
Step 8: Create an Administrator User
By default, a newly created empty CMS 12 site does not have an administrator user. The recommended way is to use
an IFirstRequestInitializer implementation.
-
Add a class (e.g.,
UsersInstaller.cs) that implementsIFirstRequestInitializerand creates a default admin user. Optimizely provides examples in their sample projects. -
Register this initializer in your
Program.cs(orStartup.csif using an older template) in theConfigureServicesmethod. -
After the first run, this user will be created. You can then remove or comment out the initializer for security.
-
Default Credentials: Typically,
admin@example.comwith passwordEpiserver123!.
-
Default Credentials: Typically,
Step 9: Run the Application
-
Via Kestrel (default): Open a terminal in your project's root and run
dotnet run. The application will start onhttp://localhost:5000(or a similar port). -
Via IIS: If you configured IIS, browse to
http://mylocalcms.local. -
Access the CMS editorial interface at
/episerver/cms(e.g.,http://localhost:5000/episerver/cmsorhttp://mylocalcms.local/episerver/cms). Log in with your created admin credentials.
Local Development Environment Setup: macOS
This section details the step-by-step process for setting up your Optimizely CMS 12 development environment on a macOS machine.
Step 1: Install .NET SDK and Visual Studio Code
- Download and install the latest .NET LTS SDK.
- Download and install Visual Studio Code.
- Install the C# extension for Visual Studio Code from the Extensions marketplace.
Step 2: Install and Configure SQL Server (via Docker)
Since SQL Server does not run natively on macOS, Docker is the recommended approach.
- Install Docker Desktop: Download and install Docker Desktop for Mac.
-
Pull SQL Server Image:
docker pull mcr.microsoft.com/mssql/server:2019-latest(You can use a newer version if available, e.g.,
2022-latest). -
Run SQL Server Container: Start a new container. Use a strong password for
SA_PASSWORD.docker run -e "ACCEPT_EULA=Y" -e "SA_PASSWORD=YourStrongPasswordHere" -p 1433:1433 --name sqlserver -d mcr.microsoft.com/mssql/server:2019-latestThis maps port 1433 on your host to the container's SQL Server port.
-
Install SQL Client: Install
Azure Data Studio
(or a similar SQL client). Connect to
localhost,1433using thesaaccount and your chosen password.
Step 3: Install Optimizely Templates and CLI Tool
Execute the commands from the prerequisites section in your terminal:
dotnet new -i EPiServer.Templates
dotnet tool install EPiServer.Net.Cli --global --add-source https://nuget.optimizely.com/feed/packages.svc/
Step 4: Create a New Optimizely CMS 12 Project
Navigate to your development directory and create a new empty Optimizely CMS project using the CLI:
mkdir ~/Projects/MyOptimizelySite
cd ~/Projects/MyOptimizelySite
dotnet new epicmsempty --name MyOptimizelyCmsProject
cd MyOptimizelyCmsProject
Step 5: Create the CMS Database
Use the Optimizely CLI tool to create and initialize the CMS database. Replace parameters with your Docker SQL settings.
The server is typically localhost.
dotnet-episerver create-cms-database MyOptimizelyCmsProject.csproj -S localhost -U sa -P "YourStrongPasswordHere"
Step 6: Create an Administrator User
Similar to Windows, implement an IFirstRequestInitializer to create a default admin user and register it in Program.cs.
After the first run, remove/comment out the initializer.
Step 7: Run the Application
Run dotnet run in your project root. The application typically starts on http://localhost:5000.
Access the editorial UI at /episerver/cms (e.g., http://localhost:5000/episerver/cms).
DXP Cloud Development Considerations
When working with Optimizely CMS 12 on the DXP Cloud, your local development environment integrates with managed cloud services.
- Environments: Integration, Preproduction, Production
- Deployments: Usually via CI/CD (Azure DevOps / GitHub Actions)
- Secrets: Managed in the DXP Portal and override appsettings
- Managed services: App Service, Azure SQL, Blob Storage, Cognitive Search
1. DXP Environments
Optimizely DXP typically provides three environments:
- Integration: Your primary development and testing environment.
- Preproduction: A staging environment for final testing before live deployment.
- Production: The live environment serving your customers.
2. Deployment
Deployments to DXP environments are typically handled via Continuous Integration/Continuous Deployment (CI/CD) pipelines, often configured in Azure DevOps or GitHub Actions. Your local development focuses on building and testing code that will eventually be pushed to these pipelines.
3. Secrets Management
Sensitive application settings (e.g., database connection strings, API keys) are managed securely within the DXP Portal
for cloud environments. These DXP Portal secrets override any corresponding settings in your
appsettings.json files. For local development, you should use:
-
appsettings.Development.json: To store non-sensitive local settings. - User Secrets: For sensitive local development secrets that should not be committed to source control.
- Environment Variables: Another option for local secrets, especially in containerized environments.
4. Database Synchronization
For local development, you often need a copy of the DXP database. Optimizely DXP provides tools (e.g., through the DXP self-service portal) to download database backups from your Integration environment. You can then restore this backup to your local SQL Server instance to work with production-like data. Similarly, you might push local database changes to the Integration environment.
5. Azure Services
Remember that the DXP Cloud leverages managed Azure services for your CMS 12 application:
- Azure App Service: For hosting your web application.
- Azure SQL Database: For the CMS database.
- Azure Blob Storage: For media and assets.
- Azure Cognitive Search: For Optimizely Search & Navigation.
Understanding these services helps in troubleshooting and optimizing your application for the cloud.
Conclusion
A well-configured development environment is paramount for effective Optimizely CMS 12 development. By following these step-by-step guides for Windows and macOS, developers can establish robust local setups. Furthermore, understanding the integration points and considerations for the Optimizely DXP Cloud ensures a smooth transition from local development to cloud-hosted environments, empowering you to build and deploy powerful digital experiences.
