.NET Core 2.0 Cheat Sheet Cover

.NET Core 2.0 on Red Hat Enterprise Linux Cheat Sheet

Don Schenck

Tags:

About

Now that Windows developers can write code that runs on Red Hat Enterprise Linux (RHEL) with almost no learning curve, the app dev environment is changing.  .NET developers can now move into microservices.  Getting started can be easy too.

In this cheat sheet, author Don Schenck provides the basics on:

  • Installing .NET Core 2.0 on Red Hat Enterprise Linux
  • Getting to a Hello World
  • How to get a simple program running
  • Running your .NET code in a Linux container

Excerpt

When you build a .NET application, you have two output options: Portable (the default) or Standalone.

Portable Application

By default, running dotnet build will build your program as a Portable Application. This means the compiler will create {appname}.dll; for example, helloworld.dll. This DLL can then be copied to any machine hosting an installation of .NET Core and it will run, regardless of operating system. For example, you could copy the DLL from a Mac onto a Linux machine (which has .NET Core installed) and it will execute.

Standalone Application

.NET Core allows you to compile an application so that it will run on a machine that does not have .NET installed. Further, you can cross-compile from any operating system to any operating system. For example, you can compile your application on your Windows 10 machine and then install and run it on a Linux machine that does not have .NET Core installed. This powerful feature of .NET Core does not exist in the previous .NET Framework. To create a standalone application, you use the dotnet publish command.3 

Note that the standalone application does not create an “.exe” file (Yet. This functionality, referred to as “.NET Native”, is scheduled for later in 2018). Like the Portable application, it creates a DLL that is run by the dotnet host. The standalone application avoids the need for a .NET Core installation by copying all of the necessary bits to the directory where you build the application. That is, you are not copying one file to the target; you must copy the entire directory and any sub-directories.

Related Cheat sheets