Create a .NET Core 2 application on Linux with Visual Studio Code


The plan is to work some with Linux and I have chosen Ubuntu 16.04 LTS because this, AFAIK, is the flavor which Azure App Service Linux containers runs, see more about that here.

I built my Ubuntu work station, by downloading the ISO from the Ubuntu site here and burning it to a DVD.  Yes, a DVD, I happened to have a DVD under my desk covered in dust and I have a workstation with a burner.  Anyway, I got a nice Lenovo T510 off EBay and it works good so far.  Ubuntu was installed very fast without any problems or difficulties.

Next, I downloaded and installed Visual Studio Code from here, as seen in Figure 1.

image

Figure 1, How to install Visual Studio Code on Ubuntu Linux

Downloaded and installed as per Figure 2.

image

Figure 2, How to install Visual Studio Code on Ubuntu Linux

As seen in Figure 3, it is required/advised to register the Microsoft Product Key as trusted, by running these commands.  Select View –> Integrated Terminal to open a BASH command window within Visual Studio Code.

sudo sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-ubuntu-xenial-prod xenial main" > /etc/apt/sources.list.d/dotnetdev.list'
sudo apt-get update
curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.gpg
sudo mv microsoft.gpg /etc/apt/trusted.gpg.d/microsoft.gpg

Notice that it needs CURL, so if you do not already have CURL, like I experienced, then you need to execute this command.

sudo apt install curl

image

Figure 3, How to install Visual Studio Code on Ubuntu Linux

Then you need to get any updates by executing these commands: (this is all documented here BTW)

sudo sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-ubuntu-xenial-prod xenial main" > /etc/apt/sources.list.d/dotnetdev.list'
sudo apt-get update

To install .NET Core 2.0 execute this command, and see Figure 4.

sudo apt-get install dotnet-sdk-2.0.0

image

Figure 4, How to install Visual Studio Code on Ubuntu Linux with .NET Core 2.0

Then check the version of the DOTNET core binaries by entering this command, see Figure 5.

dotnet --version

image

Figure 5, How to install Visual Studio Code on Ubuntu Linux with .NET Core 2.0

Execute this command and see Figure 6 to create a new .NET Core 2.0 console application:

dotnet new console

image

Figure 6, How to install Visual Studio Code on Ubuntu Linux with .NET Core 2.0

Finally, enter dontnet run and the code is executed, see Figure 7.

dotnet run

image

Figure 7, How to install Visual Studio Code on Ubuntu Linux with .NET Core 2.0

The process also runs in a DOTNET process, Figure 8, so my next step is to create a more complicated .NET Core application on Linux, then capture a dump and debug it.  That should be cool.

image

Figure 8, DOTNET process on Ubuntu Linux, debugging it

The adventure/F5 refresh has begun.

Comments (0)

Skip to main content