Optimizely CMS 12 – .NET 5.0 – Build/Deploy in DevOps (YAML)

The second I created a NET 5 project, the first anxiety-filled thought that ran through my head was something along the lines of… “How the heck am I going to build/deploy this to anywhere useful?!”

As I mentioned in my previous post about the DXCS006 error code, this is one of the first times that I have really started to work with NET 5/Core in any real capacity, so its a whole new world to me.

This all being said, the goal that I set for myself was to do the following:

  1. Learn the differences between the Build/Release process for CMS 11 & 12
  2. Create a Build Process
  3. Create a Release Process
  4. Tie it all together

In this post, we will go through the following:

How do the NUPKG requirements differ?

In Optimizely CMS 11 and below, the way that NUPKG files were built was “wwwroot/<files…>”

Optimizely CMS 11 NUPKG format

Obviously, since Optimizely CMS 12 is now on NET 5.0, the deployment format is different. The main difference is that there is no folder directly inside of the NUPKG file (wwwroot), it is just all of the dll files that were previously in the bin directory. The rest of the files are packaged up within this directory.

Example below:

Optimizely CMS 12+ NUPKG format

The easiest way to build out this format is to use the Visual Studio “Folder Deploy” or use the ‘dot net publish’ command.

Creating a Build process for NET 5.0

The first step in any project/solution is to make sure it builds, right?

Luckily, with NET 5.0, we have a new set of commands that we can use to restore and build the project.

  • Restore Nuget
  • Restore NPM (if applicable)
  • Build NPM (if applicable)
  • Build Projects/Solution

The high-level process that we’re going to do is the following: (should look familiar)

The NPM task commands have not changed, so strictly talking NET 5, the following commands will be used:

  • dot net restore
  • dot net build

It is as easy as that. A sample (and working) yaml file is below.

The uses for this in DevOps:

  • Pull Request Gate/Build
  • Commit Build Check

Creating a Build/Deploy process for NET 5.0

Now that we can Build, all that is left to do is just take what we did and package it up!

Similarly to the Build process, we are going to be leveraging the NET 5.0 commands for as much as we can.

The process should look like this all put together: (This should also look very familiar)

  • Restore Nuget
  • Restore NPM (if applicable)
  • Build NPM (if applicable)
  • Build Projects/Solution
  • Publish Projects to folder location
  • Copy Webpack files to dist folder (if applicable)
  • Pack files into NUPKG format
  • Publish Artifact NUPKG file

The NPM task, Copy file, Archive file, and Publish Artifact commands have not changed, so strictly talking NET 5, the following commands will be used:

  • dot net restore
  • dot net build
  • dot net publish

It is as easy as that. A sample (and working) yaml file is below.

The uses for this in DevOps:

  • CI/CD Release
  • Artifact creation for environment-based releases
    • The “buildConfiguration’ variable can be changed for each environment

Conclusion/TL:DR

Surprisingly, after these Build/Deploy steps are done, the rest of the DevOps processes are the same, since its just Uploading/Releasing a NUPKG file into the DXP environment. (I will have a small update to one script coming within the next few weeks)

The existing process can be viewed in my Deployment API Series – CMS 11 – Post 1, Post 2, Post 3 | Github repo

As I dig more into CMS 12, my main goal is to update my deployment scripts with any necessary updates, but also make sure to document any issues I come across with any of these deployment scenarios.

More to come!

As always, please reach out if you have any questions/comments/concerns.

Default image
Eric Markson
Senior Technical Consultant at Perficient | Optimizely MVP (Formerly Episerver)
Articles: 13

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.