.NET guide for Linux developers

By: Don Schenck

Updated: 9/29/2016

The .NET world has changed, and decidedly for the better. Not only is .NET Core now an open source framework, you can now develop and run .NET web applications on Linux. Throughout the course of this book, you will grow familiar with .NET Core, learn how to use .NET editing tools, create complex .NET web apps and debug them, and how to work with the same code in Linux and Windows.

This book explains how to:

  • Build a "hello world" console, and web apps to examine code output.

  • Create a more complex model-view-controller (MVC) web app with the ASP.NET MVC framework.

  • Develop a RESTful service with the same techniques and technologies used for your MVC website.

  • Get acquainted with several new features in Entity Framework Core 1.0.

  • Create applications built for debugging.

  • Use Visual Studio Code, the free code editor that supports several languages and operating systems.

  • Learn how to keep and run your code in Linux and edit it in Windows.

  • Perform "offroad debugging" on .NET applications from Visual Studio.

 
Transition to .NET Core cover page

Run .NET web apps on Linux now

 

 

Simple commands for .NET Core on Linux

The Dotnet New Command

The dotnet new command will create a new .NET project with the minimum amount of code and associated files necessary to run the application. When run without any additional options, it will create the “Hello World” console application. In this case, two files are created—Program.cs and project.json:


  $ ls -altr
    total 8
    -rwxrw-r--. 1 vagrant vagrant 348 Jun 15 14:43 project.json
    -rwxrw-r--. 1 vagrant vagrant 202 Jun 15 14:43 Program.cs
    drwxrwxr-x. 3 vagrant vagrant  23 Jul  8 11:24 ..
    drwxrwxr-x. 2 vagrant vagrant  42 Jul  8 11:25 .

Program.cs is the program, and it’s short and sweet:


using System;
namespace ConsoleApplication

{

      public class Program

      {

           public static void Main(string[] args)

           {

                      Console.WriteLine("Hello World");

      }

}

The result is obvious; an app that writes “Hello World” to the console.

Run .NET web apps on Linux now

 

Diving into the Application
"Hello World" Program