News

.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 at Converge 360.

comments powered by Disqus

Featured

  • Compare New GitHub Copilot Free Plan for Visual Studio/VS Code to Paid Plans

    The free plan restricts the number of completions, chat requests and access to AI models, being suitable for occasional users and small projects.

  • Diving Deep into .NET MAUI

    Ever since someone figured out that fiddling bits results in source code, developers have sought one codebase for all types of apps on all platforms, with Microsoft's latest attempt to further that effort being .NET MAUI.

  • Copilot AI Boosts Abound in New VS Code v1.96

    Microsoft improved on its new "Copilot Edit" functionality in the latest release of Visual Studio Code, v1.96, its open-source based code editor that has become the most popular in the world according to many surveys.

  • AdaBoost Regression Using C#

    Dr. James McCaffrey from Microsoft Research presents a complete end-to-end demonstration of the AdaBoost.R2 algorithm for regression problems (where the goal is to predict a single numeric value). The implementation follows the original source research paper closely, so you can use it as a guide for customization for specific scenarios.

  • Versioning and Documenting ASP.NET Core Services

    Building an API with ASP.NET Core is only half the job. If your API is going to live more than one release cycle, you're going to need to version it. If you have other people building clients for it, you're going to need to document it.

Subscribe on YouTube