I know you may be thinking… This post is another rhetoric post by this guy, yes it is. .NET Core is another product that I like, the first one being, .NET framework itself. It was last year when .NET Core got started and Microsoft said they are going to release the source code as a part of their open source environment and love. By following the open source project environment and ethics, Microsoft has been working very hard in bringing global developers toward their environments, platforms and services. For example, .NET framework works on windows, C# language is used to build Windows Store applications, C# is also the primary language in Microsoft’s web application development framework, ASP.NET and much more. The online cloud service of Microsoft is also programmed in C#; primarily . These things are interrelated to each other. Thus, when Microsoft brings all of this as an open source project, things start to get a lot better!
Everyone knows about the background of .NET Core, if you don’t know, I recommend that you read the blog post on Microsoft, Introducing .NET Core . The(ir) basic idea was to provide a framework that would work with any platform, any application type and any framework to be targeted.
Introduction and BackgroundIn this quick post, I will walk you through getting started with .NET Core, installing it on a linux machine and I will also give my views as to why install .NET Core on a Linux machine instead of Windows machine, I will then walk you through different steps of .NET Core programming and how you can use terminal based environment to perform multiple tasks. But first things first.
I am sure you have heard of .NET Core and other of the cool stuff that Microsoft has been releasing these years, From all of these services the ones that I like are:
C# 6 In my own opinion, I think the language looks cleaner now. These sugar-coated features make the language easier to write too. If you haven’t yet read, please read my previous blog post at, Experimenting with C# 6’s new features . .NET Core Of course, who wouldn’t love to use .NET on other platforms. Xamarin acquisition I’m going to try this one out tonight. Fingers crossed. Rest are all just “usual” stuff around.In this post I am going to talk about .NET Core on Linux because I have already talked about the C# stuff.

Figure 1 : .NET Core is a cross-platform programming framework by Microsoft. Why Linux for .NET Core?
Before I dive any deeper, as I had said, I will give you a few of my considerations for using .NET Core on Linux and not on Windows (yet!) and they are as following. You don’t have to take them seriously or to always consider them, they are just my views and my opinions, you are free to have your own.
1. .NET Core is not yet completeIt would take a while before .NET gets released as a public stable version. Until then, using this bleeding edge technology on your own machines won’t be a good idea and someday sooner you will consider removing the binaries. In such cases, it is always better to use it in the virtual machine somewhere. I have set up a few Linux (Ubuntu-based) virtual machines for my development purposes, and I recommend that you go the same.
Install VirtualBox (or any other virtualization software that you prefer; I like VirtualBox for its simplicity). Set up an Ubuntu environment. Remember to use Ubuntu 14.04. Later ones are not yet supported yet. Install the .NET Core on that machine.If something goes wrong. You can easily revert back where you want to. If the code plays dirty, you don’t have to worry about your data, or your machine at all.
2. Everything is command-lineWindows OS is not your OS if you like command-line interfaces. I am waiting for the BASH language to be introduced in Windows as in Ubuntu, until then, I am not going to use anything that requires a command-line interface to be used on my Windows environment. In Linux, however, everything almost has a command-line interface and since the .NET Core is a command-based program by Microsoft that is why I have enjoyed using it on Linux as compared to Windows.
Besides, on command-line interface,creating, building and running a .NET Core project is as simple as 1… 2… 3. You’ll see how, in the sections below.
3. I don’t use MacBesides these points, the only valid point left is then why shouldn’t we use Mac OS for .NET Core is because I don’t use it. You are free to use Mac OS for .NET Core development too. .NET Core does support it, its just that I don’t support that development environment.:grinning:
Installation of .NET CoreAlthough it is intended that soon, the command would be as simple as:
$ sudo apt-get install dotnetSame command is used on Mac OS X and other operating systems other than Ubuntu and Debian derivatives. But until the .NET Core is in development process that is not going to happen. Until then, there are other steps that you can perform to install the .NET Core on your own machine. I’d like to skip this part and let Microsoft give you the steps to install the framework.
Installation procedure of .NET Core on multiple platforms .
After this step, do remember to make sure that the platform has been installed successfully. In almost any environment, you can run the following command to get the success message.
> dotnet --helpIf .NET is installed, it would simply show the version and other help material on the screen. Otherwise, you may want to make sure that that procedure did not incur any problems during the installation of the packages. Before I get started, I want to show you the help material provided with “dotnet” command,
afzaal@afzaal-VirtualBox:~/Projects/Sample$ dotnet --help.NET Command Line Tools (1.0.0-preview1-002702)
Usage: dotnet [common-options] [command] [arguments]
Arguments:
[command] The command to execute
[arguments] Arguments to pass to the command
Common Options (passed before the command):
-v|--verbose Enable verbose output
--version Display .NET CLI Version Number
--info Display .NET CLI Info
Common Commands:
new Initialize a basic .NET project
restore Restore dependencies specified in the .NET project
build Builds a .NET project
publish Publishes a .NET project for deployment (including the runtime)
run Compiles and immediately executes a .NET project
test Runs unit tests using the test runner specified in the project
pack Creates a NuGet package
So, you get the point that we are going to look deeper into the commands that dotnet provides us with.
Creating a package Restoring the package Running the package Build and Run both work, run would execute, build would just build the project. That was easy. Packaging the package I will slice the stuff down to make it even more clearer and simpler to understand. One thing that you may have figured is that the option to compile the project natively is not provided as an explicit command in this set of options. As far as I can think is that this sup