Mcbeev.com - Brian McKeiver's Kentico CMS Blog

Introduction

Lately I have been asked by quite a few developers, quite a few times, if it is possible to use .Net Core 2.0 with Kentico? This is especially true with developers who are going down the path of using MVC with Kentico. So I though instead of repeating the same story over and over, I would make my opinion known publicly on my blog.

The official short answer to this question is unfortunately no. Currently with both Kentico 10 and Kentico 11 you need to still use the full ASP.NET Framework versions 4.6.x or 4.7.x. These framework versions basically set you up to also only use MVC 5 and not anything far along than that (sorry Razor Pages).

How Can You Use .Net Core Like Technology with Kentico Today

As I mention in the introduction, you simply can't use .Net Core with Kentico when you think about the traditional approach to Kentico development. There are basically two main reasons for this. First, the platform itself is mostly built with ASP.NET Webforms technology, which is simply not in .Net Core. It is basically impossible to just convert frameworks, and two, even the outstanding Kentico Integration packages for Kentico MVC development are dependent on version 4.7 of the .Net Framework.

However, there is one option to start bridging the gap between using the latest and greatest technologies that .Net has to offer inside of Kentico. And that option is to start building your class libraries and APIs targeting .Net Standard 2.0. And before you ask, no, .Net Standard 2 is not a way to reference the original ASP.Net Framework 2.0, it is something else. .Net Standard is another new option for .Net developers and it represents a collection of .Net APIs that are intended to be available on all .NET implementations. "All" in this case basically means the original .Net Framework, .Net Core, Xamarin, UWP, and others. Clear as mud right?

ASP.Net vs. .Net Core vs. .Net Standard

While a bit old, I still thought that this diagram really represents the situation well (courtesy of the .net blog)

The point is that you need to think about these frameworks as three different things. Below is how I like to think about the correct time to use each of them.

Developers should use the ASP.Net Framework when:

They need to work with, support, and maintain ASP.Net WebForms based technologies and web apps.

For Kentico developers, this specially means you will still develop your custom web parts, custom modules and custom form controls targeting .Net Framework 4.6+ in the Portal engine methodology.

They want to use the latest and greatest CLIs and editors (hint VSCode is amazing).

They want to increase the .NET API surface area your library can access, and you are okay with allowing only .NET Core apps to be compatible (.Net Core has about a dozen or so extra API libraries from Microsoft when compared to .Net Standard).

Developers should use .Net Standard when:

They want to write re-usable and portable code that could potentially run in any .Net Framework.

They want to start building class libraries, APIs, and NuGet packages with the future in mind

They want to start using newer optimized .Net APIs inside of a Kentico project and having an easier time migrating to .Net Core when the time is right.

How to use .Net Standard with Kentico

Today to use .Net Standard with Kentico (really Kentico MVC only, because in the portal engine it wouldn't make a ton of sense) you must create your new class libraries that target .Net Standard 2.0 and use a recent version of the ASP.Net Framework and a recent version of Visual Studio to make it all work. Below are your two choices for making it work.

The Minimum Requirements: You must be using at least Kentico 9.0 with ASP.Net Framework version 4.6.1, and using at least Visual Studio 2017 version 15.3 or higher.

In this model, when you build and run a solution that contains references to any .Net Standard 2.0 component Visual Studio helps out by automatically referencing and copying in the netstandard.dll (which is what you need) into your Kentico site's bin directory and it should just work. To verify you should see the dll in the bin folder like so:

The Recommended Requirements: If you can, go with Kentico 11.0 using ASP.NET Framework 4.7.1, and using Visual Studio 2017 version 15.5 or higher.

With the recommended requirements you don't need to worry about the netstandard.dll. It is already part of the ASP.Net Framework 4.7.1. No extra files are needed at all.

Even though the Kentico 11.0 installer only gives you a choice of .Net 4.6 or .Net 4.7 you can updated your project's target framework to 4.7.1 right after the install it should work just fine. I have tested it.

The Future

If you are following the official Kentico product roadmap there are already some references to where Kentico is going. Kentico 12.0 is going to focus on bringing Kentico MVC to newer .Net technologies like .Net Core and having a full visual MVC Page builder. I honestly cannot wait to see that in action.

Conclusion

Please remember, these are just my opinions and experiences here. I don't actually work for Kentico and can't speak for them. But I do beleive that this post does answer the question quite well on if you can use .Net Core with Kentico. I am also not trying to lead you astray. I have tested each of the scenarios I did mention in this post and seen them work, but I'm not infallible. If you find other options or have simalir experiences please let me know via the comments.

Be the first to know about my latest Kentico Tips & Tricks!

About Brian McKeiver

I have over 17 years of experience in web development, mainly at BizStream. I'm passionate about software platforms and technologies that can help solve real world problems. I specialize in architecting solutions that use Kentico CMS, Kentico EMS, ASP.NET Content Management Systems, and the Microsoft Azure platform.

I enjoy hanging out with my wife, chasing around my three children and vigorously rooting for the Michigan State Spartans and Detroit Lions.