In order to run .NET applications on Linux operating systems, Mono used to be the only option. Now, Microsoft has released .NET Core that can build and run .NET applications on any OS including Windows, OSX and Linux. In this post, we are going to install both .NET Core Framework RC1 and RC2, build and run a simple Hello World
application, and compare RC1 to RC2.
Installing .NET Core RC1
By following the official document, Installing ASP.NET 5 On Linux, we can install .NET Core Framework onto Amazon Linux, which is a variation of RHEL/CentOS. In addition to this, we have to install Mono to run DNX because, in RC1, .NET Core only supports full framework like Mono.
However, the official document from Mono doesn’t work well on Amazon Linux. When we follow the steps, we’re facing the dependency error:
This needs to be sorted out before installing Mono. This post describes steps to install the missing dependencies on Amazon Linux. Once we install dependencies, then Mono can be easily installed.
Now, we’ve got Mono installed, and DNVM, DNU and DNX installed onto Amazon Linux. Then clone the following repository and run the console application sample.
There is a very high chance that our Amazon Linux VM doesn’t have git installed. In this case, before cloning the repo, git should be installed first. Then build and run it like:
Once we successfully run the code, we’ll be able to see like:
.NET Core also provides an interesting option, called --native
. This enables developers to build an OS specific native binaries. With this native binaries, we can run that natively compiled binary on another Amazon Linux without .NET Core being installed. Follow the code bits and we should be able to see the natively compiled binaries.
However, we see a disappointing result back like:
Because we cannot install .NET Core CLR onto Amazon Linux, this native build is not possible.
Installing .NET Core RC2
Releasing .NET Core RC2 makes Amazon Linux build and run .NET Core applications with Core CLR runtime. Mono is not required any longer. Follow the official document to install .NET Core on Amazon Linux. Again, Amazon Linux is a variation of RHEL/CentOS so we can use their instructions.
Once installation is complete, run the sample Hello World
app from the instruction and we’ll be able to see the screen like:
How about the --native
option in RC2?
When we check this option on either dotnet build
or dotnet publish
, we can’t find it. According to the issue on the GitHub repository, the --native
option was excluded. Microsoft is planning to put this option back after the 1.0 official release.
Why Is the --native
Option Important?
Now, we might have a question.
Why is the
--native
option important to us?
Actually, running .NET Core applications itself, there is no problem at all, with/without the option. However, there is a clear requirement to use native binary. For example, if we want to use our own binaries with AWS Lambda, that native binary build option should be necessary. We hope this option is coming back sooner or later.
Comments are closed.