.NET Introduces More Cross-Platform Support

If you have been following the progression of the .NET world, you will no doubt have noticed a shift from the traditional Windows-based framework to a cross-platform library that allows programs to be run on a variety of platforms, including:

  • Windows
  • Linux
  • macOS
  • Docker

That means that developers can now develop and target solutions to any of these platforms. The introduction of .NET Core has made the move to cross-platform compatibility possible. The new .NET Core is a bit of a departure from traditional .NET Framework. While similar in features, they are quite different.

What does that mean for legacy .NET code? I cringe to say the word legacy since I was around when the original .NET was introduced about twenty or so years ago. Legacy for me is COBOL, but that is a story for another day. But the truth is that “legacy” code will require some work to bring it forward. .NET Core has enough changes to make it interesting.

You might be asking “Is it worth it?” Well, I will give you the same answer that many .NET developers will provide “It depends.”

If you are doing a new project, then the answer is a no brainer. Target the new .NET Core libraries and make use of the advancements available:

  • Web applications can take advantage of .NET Blazor and the ability to build responsive web applications that run either on the server or directly in the browser using webassembly.
  • Applications can be hosted on either Windows or Linux platforms. .NET Core code can execute on either.
  • Traditional application types are still supported: console, ASP.NET MVC, ASP.NET Web API, etc. With the bonus that many of them will run on other platforms.
  • Tooling is available for Linux and macOS platforms, as well. Visual Studio Code provides a free and open-source editing environment that operates in Windows, macOS and Linux. You can also use Visual Studio on Windows and macOS.
  • Docker loves .NET Core which is in large part due to the support for Linux. It is much easier to package your applications in containers for quick deployment. Microsoft provides support for many of its tools in containers. Other vendors do as well.

There is a lot of flexibility. A bit of a learning curve as some of the components that are popular, such as Entity Framework, have a slightly different spin on them. So, strap on your boots and get learning.

What about my “legacy” .NET Framework application? Well, the answer is a bit trickier. If you find yourself just maintaining and tweaking your application with no view towards hosting it cross-platform, then I would say stay where you are. However, if you want to leverage any of the advantages of the new .NET Core platform and eco-system, then you are in for a bit of work.

The amount of work will be significant, but not insurmountable. I looked at one application I had written for a client. The original app had about sixty hours of work in it. I estimated it might take me 20 hours or so to migrate and fix up the code. About 30% of the original effort. I may be wrong. It could be more efficient. But again, it would come down to what advantage it would provide for my client to do the work.

Don’t forget that twenty hours of my work would then translate to a full QA cycle for the client, as well. So, the advantages of moving would have to be there. The other danger would be the temptation to refactor the code to leverage new features. That could be a rabbit hole that got very deep very quickly.

.NET Core is where the investment is going. I love that about Microsoft. They always promise to maintain the old while working on the new, but you can clearly see where the bulk of the investment is going. Case in point is another new feature which makes targeting applications cross-platform even better.

.NET MAUI (Multi-platform App UI) is the new feature on the block. Imagine building applications that could be deployed to run on Windows, macOS, Android, and iOS. Well now you can with .NET MAUI.

Starting with .NET Core 6, the .NET MAUI framework allows you to build applications that can run in all these environments. This is the evolution of the toolset Microsoft acquired known as Xamarin.

Xamarin focused on building applications that could run on Android and iOS platforms. But now, .NET MAUI makes that same approach available for applications that will run on all four platforms.

Visual Studio is evolving tooling to support building these applications. Visual Studio Code could be used for building code, but my sense is you will want to target using Visual Studio for ease of development.

Another twist is that you can turn your .NET Blazor web application into a native application using .NET MAUI. The platform uses a special component developed to allow .NET MAUI to host the web pages. I saw a demo from the recent Ignite conference and it was seriously cool. You can either host the Razor web pages as is or do a mix of .NET MAUI and Razor web pages to create the best mix.

I can remember several times in my thirty plus year career that I said it was a cool time to be alive and be a programmer. But I have to say it is yet again a cool time with many advances. Of course, if you have systems built in “legacy” .NET Framework code, then you have to weigh the cost to upgrade it with the cost to stay with the status quo.

As a developer, I can say without hesitation that there is never a dull moment. The opportunity to advance our state of the art is still moving forward at an incredible pace. Fortunately, technology is helping us to code faster. But that is a story for another blog post.