Chapter 16. Packaging and Deploying Your Code Cross-Platform

This chapter is about porting existing .NET Framework codebases to .NET Core, publishing your .NET Core apps and libraries, creating and distributing NuGet packages, and deploying your code cross-platform and to the cloud.

This chapter covers the following topics:

  • Porting to .NET Core
  • Sharing code cross-platform with .NET Standard class libraries
  • Understanding NuGet packages
  • Publishing your applications
  • Deploying to the cloud
  • Developing on and for Linux

Porting to .NET Core

If you are an existing .NET developer, then you may have existing applications written for older platforms, such as .NET Framework, that you are wondering if you should port to .NET Core.

You should consider carefully if porting is the right choice for your code. Sometimes, the best choice is not to port.

Could you port?

.NET Core has great support for the following types of applications:

  • ASP.NET Core MVC web applications
  • ASP.NET Core Web API web services (REST/HTTP)
  • Universal Windows Platform (UWP) applications
  • Console applications

.NET Core does not support the following types of applications:

  • ASP.NET Web Forms web applications
  • Windows Forms desktop applications
  • Windows Presentation Foundation (WPF) desktop applications
  • Silverlight applications

Luckily, WPF and Silverlight applications use a dialect of XAML which is like the XAML dialect used by UWP and Xamarin.Forms.

Should you port?

Even if you could port, should you? What benefits do you gain? Some common benefits include:

  • Deployment to Linux or Docker: These OSes are lightweight and cost-effective as web application and web service platforms, especially when compared to Windows Server.
  • Removal of dependency on IIS and System.Web.dll: Even if you continue to deploy to Windows Server, ASP.NET Core can be hosted on lightweight, higher performance Kestrel (or other) web servers.
  • Command-line tools that developers and administrators use to automate their tasks are written as console applications. The ability to run a single tool cross-platform is very useful.

Differences between .NET Framework and .NET Core

There are three key differences:

  • .NET Core is distributed as NuGet packages, so each application can be deployed with its own app-local copy of the version of .NET Core that it needs. .NET Framework is distributed as a system-wide shared set of assemblies (literally, in the Global Assembly Cache).
  • .NET Core is split into small, layered components, so a minimal deployment can be performed. .NET Framework is a monolithic deployment.
  • .NET Core removes unnecessary components. As well as removing older technologies such as Windows Forms and Web Forms, .NET Core removes non-cross-platform features such as AppDomains, .NET Remoting, and binary serialization.

Understanding the .NET Portability Analyzer

Microsoft has a useful tool that you can run against your existing applications to generate a report for porting. Watch a demonstration of the tool at the following link:

https://channel9.msdn.com/Blogs/Seth-Juarez/A-Brief-Look-at-the-NET-Portability-Analyzer

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.116.47.25