.NET Core: To Port or Not to Port?

Much buzz accompanied the release of .NET Core 2.0 this summer, but it's actually not the best .NET implementation target to choose for all projects.

When it was announced in June of last year, .NET Core was described by Microsoft as a "cross-platform, open source, and modular .NET platform for creating modern Web apps, microservices, libraries and console applications" to run on Windows, Linux and Mac.

As .NET Core 2.0 and the related .NET Standard 2.0 provided access to tens of thousands more .NET APIs than previous versions, many developers considered switching to the new implementation and porting existing projects to it.

However, Microsoft is advising developers to pump the brakes a little on that notion and make sure their projects are really a good fit for moving to .NET Core.

"So there are good reasons why you may not want to port to .NET Core," Microsoft's Immo Landwerth said recently in announcing a tool to do just that. Historically, those reasons included the lack of APIs, as mentioned. However, even with the new APIs, Landwerth emphasized early in his post and at the beginning of an accompanying video that developers should consider wisely before making this move.

"But still, depending on what you're doing, if you're building a Windows Forms apps or UWP apps or using WebForms apps, you probably should not port to .NET Core yet because the .NET Framework is still the best bet that you can take," Landwerth said in a video.

In the video, Immowerth boiled the issue down to the following.

Reasons not to port:

  • You're building desktop applications (WinForms, WPF)
  • You're building ASP.NET Web Forms apps
  • You're simply happy with the status quo

Reasons to port:

  • You want to build highly scalable Web apps
  • You want to run your Web apps on Linux
  • You want self-contained deployments

"But before you start porting, you should understand what you want to accomplish with the migration," Landwerth said in his blog post. "Just porting to .NET Core because it's a new .NET implementation isn't a good enough reason (unless you're a True Fan).

".NET Core is optimized for building highly scalable web applications, running on Windows, macOS or Linux. If you're building Windows desktop applications, then the .NET Framework is the best choice for you. Take a look at our documentation for more details on how to choose between .NET Core and .NET Framework.

That documentation -- which actually specifically addresses server-side applications -- includes more ".NET Core or .NET Framework" guidance.

Use .NET Core for your server application when:

  • You have cross-platform needs
  • You are targeting microservices
  • You are using Docker containers
  • You need high-performance and scalable systems
  • You need side-by-side .NET versions per application

Use .NET Framework for your server application when:

  • Your app currently uses .NET Framework (recommendation is to extend instead of migrating)
  • Your app uses third-party .NET libraries or NuGet packages not available for .NET Core
  • Your app uses .NET technologies that aren't available for .NET Core
  • Your app uses a platform that doesn't support .NET Core

After considering all those factors, developers who decide that porting to .NET Core is the way to go can use the new Windows Compatibility Pack introduced by Landwerth to do just that.

"It provides access to an additional 20,000 APIs, compared to what is available in .NET Core," Landwerth said of the package, which is still being developed in a preview program. "This includes drawing, EventLog, WMI, Performance Counters, and Windows Services."

Landwerth's post goes into detail on how to use the tool, in conjunction with a new API Analyzer to help developers ensure their projects don't depend on Windows-only APIs.

However, just as he began the lengthy post, Landwerth ended it with yet another caution: "But remember that the .NET Framework is still the best choice for building desktop applications as well as Web Form-based Web applications. If you're happy on the .NET Framework, there is also no reason to port to .NET Core."

About the Author

David Ramel is an editor and writer for Converge360.

comments powered by Disqus


Subscribe on YouTube