Install .NET Core 2.2 SDK in Debian Stretch

First we need to install Net Core SDK. In order to do that we need to add to our repositories list the Microsoft package repository for Debian 9. Also, to access the repositories we will need to register the Microsoft key.

These are the commands we got to run from a command line:

wget -qO- | gpg --dearmor > microsoft.asc.gpg
mv microsoft.asc.gpg /etc/apt/trusted.gpg.d/
wget -q
mv prod.list /etc/apt/sources.list.d/microsoft-prod.list
chown root:root /etc/apt/trusted.gpg.d/microsoft.asc.gpg
chown root:root /etc/apt/sources.list.d/microsoft-prod.list

If we have not installed yet the package apt-transport-https, we do it now from the cli:

apt-get install apt-transport-https

Now we execute the following commands to see which versions of the Net Core SDK are available in the repository:

apt-get update
apt-cache search dotnet-sdk

When running apt-cache search dotnet-sdk we will see that we have the sdk 2.02.1, sdk 2.2, … I am going to install 2.2:

apt-get install dotnet-sdk-2.2

To check if .Net Core is correctly installed in your machine you can run this command:

dotnet --version

That should return the version of dotnet installed.

Install Visual Code in Debian Stretch

If we are going to do .Net development in Linux, we will need and editor or IDE. I am going to use Visual Code, you can use the code editor of your choice. Here are some other alternatives monodevelop cross platform IDE for C#, etc or Rider, Jetbrains IDE for NEt.Core, Xamarin, etc.

As I was saying, I will go with Visual Code so I’ll download the .deb package from and I’ll install it using gdebi:

gdebi code_1.30.1-1545156774_amd64

Visual Code is not an specific language editor: it allows you to write code in a wide selection of languages. This versatility is achieved through the use of extensions that add features and language support to the Visual Code editor.

Since we are interested in developing .Net Core applications, we would welcome an extension that adds syntax highlighting for C#, IntelleSense, etc. Luckily we can download such an extension – the C# extension – from the VS Code Marketplace.

Create a .Net Core Web Project in Debian Stretch

Let’s create a folder for out project:

mkdir TestProject
cd TestProject

Now let’s run this command to create all the folders and file structure of a Core web project:

dotnet new web
dotnet restore

Check Microsoft’s documentation for a list of the available templates for the new command, or alternatively run this command on the console:

dotnet new -l

To run the project we use this command:

dotnet run

It should tell us that our application is ready an available at this url: http://localhost:5000. Indeed, if we open a browser and go the indicated url, we will see this:
web application
Not very impressive, I admit it, but it shows that our application is running fine. Now if we want to start developing, we can use VisualCode to open the TestProject folder.

When I tried to compile the project in Visual Studio I got an error like this one:
razor error in visual code

Failed to load , error: cannot open shared object file: No such file or directory
Failed to bind to CoreCLR at '/home/dim/.vscode/extensions/ms-vscode.csharp-1.17.0/.razor/'
[Error - 18:12:19] Connection to server is erroring. Shutting down server.
[Error - 18:12:19] Connection to server is erroring. Shutting down server.
[Error - 18:12:19] Connection to server is erroring. Shutting down server.

The same issue has been reported in the GitHub Razor.VSCode project and – as suggested in that site – it was solved by installing the libunwind8 package.

apt-get install libunwind8

That issue solved, you can build, and launch the project from VisualCode.