Create CMS 12 Projects using dotnet command

Thursday, March 17, 2022 | CMS Commerce
Surjit

Surjit Bharath

Director of Hidden Foundry

Optimizely Most Valued Professional (OMVP), Subject Matter Expert (SME), CMS and Commerce certified

Contact Me

Install Episerver CLI

Branding aside, the episerver cli is a set of tools that allow you perform various actions such as creating a database or setting up an admin user.

dotnet tool install EPiServer.Net.Cli --global

To confirm the cli has been installed:

dotnet tool list -g

(Use later) Update the cli:

dotnet tool update episerver.net.cli -g

 

Using CLI

Run the cli without any commands and you can see v1 has four commands ready to go. add-admin-user you can use but there's some additional steps you need to take in once inside the CMS to fully setup an admin user. For now I recommend following on and CMS setup will create one for you.

dotnet-episerver

 

Install Project Templates

The project templates we are so used to creating from Visual Studio can now be done via command line.

dotnet new -i Episerver.Templates

List the projects we can create. Do not use the Episerver projects, those are legacy. Instead use the new branded ones listed at the bottom.

dotnet new list epi

Image from https://lh6.googleusercontent.com/TxbzDaOQkQ0FJxoIcpn4JMPwWZvQinAQPjC7hUfwmjjfarpBOO_34MOM6XAWTXSJOP8Jp36ViU4EP4Ox8G5tZdwAllyrN-wKRgdxjZWM8IqzFMA4rxNZhHo0PzBH7GpasZLJbnxP

(Use later) check for updated templates:

dotnet new update --check-only

(Use later) Apply updates:

dotnet new update

 

Create Alloy

Create a new folder and install Alloy:

dotnet new epi-alloy-mvc

Image from https://lh5.googleusercontent.com/ahZYTnRv7B82--pvadf5iTmEmpa_fw8Ygzfno0dC8mXYGaULo7qAnY0W-WQXqlaWCokv41pM05_XVplEyBNIDVWo4fG_-p2w29jGkcl9X0YyN2yLLwHNcmJKGE3SFjfgazZYbig5


Create a new Empty Project

If you'd prefer a empty site then:

dotnet new epi-cms-empty

Image from https://lh3.googleusercontent.com/XhCVt8uGQcPpLuKYjTJ8IVAOcnheHJgDT2T8oZRY0GHkuxQ-ykmO65LcIWd1l9pHmZqDL3e3w6EYD0vJ6ALfnKFJDBu_qV3Hp_jLcgOIaoboWria0OOtUB-6X95tAg5kuD8t-1OT

 

Run the application

Compile and run the application. This is not specific to Optimizely, it is how you run any .NET Core and .NET 5 + application.

dotnet run

This serves your application under https://localhost:5000/. It may not open automatically in your browser so navigate to it manually.

 

Register a new admin user

Navigate to https://localhost:5000/util/register and fill out the form to create your first admin user of the site.

You'll notice if you attempt to navigate to this page again after registering then instead you'll be presented with a 404.

 

CMS Admin

To get into admin mode, navigate to the following: https://localhost:5000/episerver/cms/ . If you're doing this straight after registration then you will already be logged in.

You are now ready to develop!

 

Other useful dotnet commands

Clear all nuget cache locally

dotnet nuget locals all --clear

Restore nuget packagereferences directly from nuget feed

dotnet restore --no-cache --force

;