First contact with .Net Core 3 and Visual Studio Code on Linux Ubuntu

Nicola La Rocca
4 min readJul 17, 2018

Introduction

In this short tutorial we’re going to use Microsoft .Net Core 3 SDK and Microsoft Visual Studio Core to create a simple console project with C# language on Linux Ubuntu OS.

Tutorials requirements

  1. PC or VM with Linux Ubuntu
  2. Microsoft Visual Studio Code
  3. Microsoft .Net Core 3

How to get and install required software

We can freely get Visual Studio Core from Microsoft’s site

Click on version suitable with your operating system (in my case Linux Ubuntu)

Proceed with installation and click the icon to start Visual Studio Code

One of the Visual Studio Code most interesting features is its modularity; programmers can install numerous extensions related to different technologies. In this tutorial we’re going to install language C# extension. Click on extensions icon and search C#

Proceed to install C# extension showed in the following image

If not present, install GIT with the following instruction on Ubuntu

Visual Studio Code is now ready to use but, before to create our first test project, we have to install .NET Core 3 SDK.

Open Microsoft site and follow the instructions to install SDK on Ubuntu Linux

At the end of installation, we can check SDK using the following command on a Linux terminal

First Test Project Creation

Experienced programmers in the use of Visual Studio on Windows OS, usually start a new project using available wizard that permit to create several project’s base elements. In Visual Studio Code we have to use Linux terminal and .Net Core CLI available commands.

Start Linux terminal or use Visual Studio terminal and write dotnet -h. This command permit to view SDK overall instructions.

Among the numerous instructions, we will use the “New” command which permit to create a new project.

Write dotnet new -h command to get more information about new project creation.

As we can see .Net Core permit to create several project types.

In this first example we’re going to create a simple Console Application project which require “console” short name and C# as default language.

Create a new folder and then, write the following command on linux terminal (or Visual Studio Terminal)

dotnet new console -n TestConsole

With -n option we are writing project name.

Microsoft .Net CLI will create our new Console project which we can load and modify using Visual Studio Code.

Open project folder and write code .

The Visual Studio Code will start showing our project ready to be modified

To view and modify project file clicks on Explorer and then on Program.CS. Modify C# code adding preferred elements and save clicking on File → Save or using CTRL + S.

We can debug project clicking on Debug icon or using F5. We can insert breakpoint and starting BUILD project clicking on Start Debugging button.

We can BUILD our project using Linux Terminal and writing dotnet build command in project folder

We can EXECUTE our project using dotnet run command

Conclusion

In this simple tutorial we’ve installed all basic software to start using C# on Linux Ubuntu and we’ve created our first .Net Core 3 project using the powerful Visual Studio Code. In the next tutorial we’ll analyse how to create a full Web Api on Linux Ubuntu.

--

--