.NET Core ready?

27 Apr, 2017 | 5 minutes read
A good programmer is someone who looks both ways before crossing a one-way street. - Doug Linder

What is .NET Core?

During the past several years, Microsoft had countless changes. When talking about the future Microsoft is moving towards, and the developers that are creating products using the Microsoft tools can’t seem to avoid mentioning .Net Core. .NET Core is .NET implementation with characteristics such as high performances, security, modularity for creating services and applications on different platforms. Several years ago, for the developers within the Microsoft ecosphere, it was nearly impossible to build a cross-platform application with such ease. .NET Core represents the revolution that is happening nowadays. That is a huge step forward to the future, and we cannot forget the fact that .NET Core is an open source with complete cross-platform implementation of the CLR, virtual machine that manages the execution of .NET programs.

Why Core is the future?

Regarding this question, the opinions are divided. We cannot ignore the fact that Microsoft invests a lot in .NET Core. It also cannot be stated that Microsoft always had good predictions, but this time they are a little bit more cautious. Most frequent comments in the programming community are that this is the radical change they were hoping for in years, and that they are aware that the .NET Framework is not carved in stone that will stay forever. Almost every C# developer has already tried basic “Hello World” program in .NET Core and everyone agrees that this is something very powerful. But, you can rarely find someone that will risk to work in .NET Core on a new project or new application for a client, mainly because of the stability they are getting using the good “old” .NET Framework.

Who can use .NET Core?

Looking into the future, everyone, or most of the developers in the Microsoft world can use .NET Core. At this moment, .NET Core is used by the early adopters and adventurers who like to work on the “bleeding edge” of the technology. Besides a cross-platform, here are several positive features that I have come across while working with .NET Core:

  • Performance. ASP.NET Core uses Kestrel, a cross-platform web server. The main characteristic of the applications hosted on Kestrel is their speed and Microsoft constantly works on optimizing and improving the results even more. Regardless of the type of application, modern users expect fast results. Several milliseconds of difference may not sound like something big, but they can have a significant impact on total processing time.
  • Dependency injection isn’t just supported out of the box in ASP.NET Core, it’s used extensively by the product itself.
  • .NET Core is the best technology when working on a solution with microservice oriented architecture implementation using Docker containers
  • When hostingNET Core application, there is an advantage of including only the relevant libraries instead of the whole framework.
  • And one of the most important things is that Core has the largest community, compared to other .NET Frameworks. Those developers constantly work on improvements, optimizations, implementing new features and fixing the bugs.

Is .NET Core production ready?

As good as those benefits looks, there are still a lot of things that .NET Core is missing. Or at least, things that we got used to before while working with its stable predecessor. .NET Framework is stable, well documented and there are tons of third-party libraries for it. Microsoft does not plan to abandon .NET Framework any time soon. They prove that by announcing the .NET Framework 4.7. So, if the project you are working on does not have space to experiment, time and money, or it’s critical enough, still, the best solution is not to upgrade it yet.

Also, some of the extensions and libraries that are widely used are not updated for .NET Core, so they cannot be used partially or fully. And last but not least, the time that you will spend for transferring one existing big project in .NET Core could be considerable and the risk will not be worthy. At this moment, there are still key libraries that are missing: like connectors for MySQL (in prerelease now) and Oracle, libraries that use Windows Workflows, SignalR (Partially), Active directory etc.

All those items in the list represent obstacles, and even if we build our implementations, they will slow down our task significantly and will affect user’s acceptance of .NET Core. Microsoft sees .NET Core as a new generation of the .NET, but if we have to build an application in a technology that lacks usual features doesn’t support that claim.

Does it mean that we should ignore it? Of course not! We cannot ignore the future and we must evolve in the process. Maybe .NET Core is still not ready for production applications, but we should be ready for .NET Core!

Create .NET Core Ready applications

“HD Ready” is a term for a display that is able to show high-definition picture, but does not have a built-in HD tuner. In the same analogy, we can use “.NET Core Ready” as a term that describes applications that are built using the structure and libraries of the .NET Core project, but still they are targeting some older .NET Framework like 4.6.1.

How can we do that? If we are working with .NET Core 1.0 when we should modify the project.json file instead of:

{
  "frameworks": {
    " netcoreapp1.0": {}
  }
}

We should use

{
  "frameworks": {
    "net461": {}
  }
}

And if we use .NET Core 1.1+ we should update the csproj file:

<PropertyGroup>
  <TargetFrameworks>netcoreapp1.1</TargetFrameworks>
</PropertyGroup>

To

<PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net461</TargetFramework>
    <PreserveCompilationContext>true</PreserveCompilationContext>
</PropertyGroup>

Next, we will be able to use any library that is not fully supported in the .NET Core version. I’ve used this with several libraries and they are very stable, fast and they work without any problems. Later when I changed it back to netcoreapp1.1, NUGET tried to update the libraries needed for the project and gave me an error that there are several libraries not supported in the .NET Core. All we need to do now is wait. When those libraries are available for .NET Core, we will switch back to that property again. As we stated before, Core is the technology that Microsoft is putting its money into. Sooner or later it will become the prime framework that Microsoft will support. So, do not hesitate to try .Net Core.</

Till then, we are ready to embrace those changes!