It's been right around a year and half since my team and I decided to give this new Headless CMS thing a try. We really wanted to use it for a real world solution, not just a starter site. So for the original scope of the project, we leveraged Kentico Cloud to build www.CaseStream.net in 12 days. It was actually a lot of fun to create the new site because I was able to use the latest and greatest technology at the time. It was like a breathe of fresh air.
But that was in 2017, and time flies, ridiculously fast. Just ask one of my new employees who's 90 day review didn't exactly happen anywhere near 90 days, or 120 days.... Fast forward to where we are at here in the end of July 2018, and that's like 15 months that went by in a blink of the eye.
Since that first release of www.CaseStream.net, Kentico has been rapidly improving Kentico Cloud, adding new feature after new feature. I have been keeping my eye on it, and been able to play with a few demos of the new features here and there, but it wasn't until about a week ago that I was able to put those features into real use. I'd say the feature that really got me motivated however was the new responsive image based API (named the Image transformation API) that Kentico Cloud released in June of this year.
After reading the documentation and excellent blog post on transforming images, I decided to fire up my code and try to add this feature to the site. That's when I realized I had a problem. Quite a bit had changed, and my code was in dire need of an update. But I always love a challenge.
Keep reading to see how I leveled up my Kentico Cloud ASP.Net MVC site to .Net Core 2.1, the Kentico Cloud Delivery SDK 4.14, and added support for a few of those lovely new Kentico Cloud features.
Leveling Up My Kentico Cloud CaseStream.net Site
Kentico Cloud was not the only thing that had changed in the last 15 months. Microsoft also has been updating the .Net Core framework rapidly, and of course the features of Azure are always receiving updates. After checking out the latest branch of the code and looking at my project properties I realized that .Net Core 1.1 just wasn't going to cut it any longer. Especially since 1.1 was in Long Term Support (LTS) status, and .Net Core 2.0 is slated to be LTS in October 2018. Now, I didn't exactly choose .Net Core 1.1, it just came by default when I used the Kentico Cloud Boilerplate open source project. That problem is shown below:
That means it is time to upgrade to .Net Core 2.1 for any .Net Core projects you have. Luckily this is a somewhat easy process. I did have to update my home development workstation though. I didn't even have 2.1 installed yet there.
Once the new SDK was installed I was able to switch to .Net Core 2.1 as the target framework for the project.
After a rebuild of the project, I wish I could say everything just worked. It did not. There is simply just too much that had changed between the frameworks and references that the KC Boiler Plate project has. The question was, how the heck was this to be resolved. My solution to this problem was to leverage a new copy of the KC Boiler Plate project (release 2.1). Luckily the Kentico Cloud team had already gone through and updated the solution. I was able to have that solution open in another Visual Studio instance and do some side by side comparisons. The key was comparing the .csproj files and Nuget Package references.
Even after switching to .Net Core 2.1 as the target framework, the .csproj file was still in bad shape:
I updated all the references to the packages and main PropertyGroup to match the fresh new Boiler Platt project csproj file and that was the thing that made it work... almost. I was past the NuGet Restore errors and other hard solution errors that Visual Studio likes to throw. The final copy looks like:
Correcting the .csproj file and other references allowed me to match the new NuGet Packages that the project should use for .Net Core 2.1. See how clean and simple the references are now? Good work Kentico Cloud community!
Then after a rebuild I was just at the "normal" code erroring out. But at least I was out of .dll hell. Kids, if you don't know what .dll hell is, you have no idea how easy you have it now in the software development world...
Dealing with the Code Errors
At this point, having an error in the CachedDeliveryClient means that we need to start doing the same thing as with the package references (comparing my code vs the newest release). I use WinMerge to do this, but you could use any diff tool you want. There were quite a few differences. Click on the screen shot to enlarge the photo so you can read it.
The largest difference is that the CachedDeliveryClient now has Reactive Cache Manager implementation. That means it caches a heck of a lot better than before plus supports the new Kentico Cloud feature for using WebHooks to do cache invalidation. To use all this new code, I had to basically merge in the whole project of code. Don't worry it isn't actually as bad as it sounds. Plus the benefit is that you get to learn all of the pieces that make up the boiler plate solution. I feel like I have a much better understanding of the solution now. The key files that I merged were this one, Startup.cs, Program.cs, appsettings.json. These all had fairly big changes. There were many other small helpers and extension files that I merged in as well.
One rather interesting benefit of .Net Core 2.1 is more support for the async / await pattern. I had to update all of my Partial View rendering calls in all of my Views to use the async helper. I had this error:
I was able to resolve it, with a little help from the official docs, by updating the call to:
Once all of code was merged in and I rebuilt the project, the site just worked! Hurray. The first part of the update was complete. I actually felt pretty good about getting all this going in about a day of work.
This post is turning out to be quite long, so I am going to break it up into two parts. Keep reading part 2 of Leveling Up a Kentico Cloud Project here. In the next part I am going to talk about adding in the new features that started out this whole thing in the first place. Namely: the Image Transformation ability and Webhook ability that Kentico Cloud now has.