How to install Visual Studio Code and .NET Core on RHEL 7

Visual Studio Code


It was November 2014 when Microsoft announced the open sourcing of .NET with a project named .NET Core. It was announced as a smaller set of the .NET Framework, with many of the same APIs, and including “runtime, framework, compiler and tools components that support a variety of operating systems and chip targets” as stated in MSDN. This was an important announcement because .NET is a widely-used general development platform.
One year later, Red Hat and Microsoft announced a collaboration which resulted in access to .NET on Red Hat Enterprise Linux and Red Hat OpenShift.

In June 2016, Red Hat announced that .NET would be available via the integrated hybrid support partnership between both companies, making “Red Hat the only commercial Linux distribution to feature full, enterprise-grade support for .NET, opening up platform choice for enterprises seeking to use .NET on a flexible Linux and container-based environments.”

Enable .NET Core repositories

If you use RHEL 7 for development, you should have a subscription as a developer (at no-cost through the Red Hat Developer Toolset).

So, check it with:
# subscription-manager repos –list | egrep dotnet

If there are repositories listed, it means that .NET can be installed. So, enable the repo:

# subscription-manager repos --enable=rhel-7-server-dotnet-rpms

Install .NET Core

Once the repository is enabled, it’s possible to install .NET with yum. Just:

# yum install rh-dotnetcore11

Working with .NET Core

The .NET Core packages are designed to allow multiple versions of software to be installed concurrently. To allow this, every package is added to the runtime environment with the command

scl enable

. When running, it environment variables and then runs the specified command. Its changes only affect the command that is run by


and processes that are run from that command. This helps in maintaining a “clean” environment.

So, in a new terminal window, as user, execute the command:

$ scl enable rh-dotnetcore11 bash

This will start a new Bash instance, which has access to .NET Core 1.1 (the one installed previously).

dotnet --version

for checking if everything works.
Now, just executing the


 command will shut down .NET and return to a “normal” Bash.

Install Visual Studio Code

GNU/Linux systems have a lot of text editors and IDEs, so anyone can use the tool he likes the most for writing code.
But, in the case of .NET Core and C#, a good option could be Visual Studio Code, the open source editor written by Microsoft.
To install the 64-bit code editor on Red Hat Enterprise Linux 7, execute the following steps:

First, set up the yum repository as follows:

# rpm --import
# sh -c 'echo -e "[code]\nname=Visual Studio Code\nbaseurl=\nenabled=1\ngpgcheck=1\ngpgkey=" > /etc/yum.repos.d/vscode.repo'

Next, update the package cache and install Visual Studio with:

# yum check-update
# yum install code

Using Visual Studio Code with .NET Core



start the editor with .NET Core. The syntax is the same as the “Bash example”:

$ scl enable rh-dotnetcore11 code

Click on File->Open Folder and open the folder in which the Hello World program will be saved; Visual Studio Code will ask to install a C# extension. Do it.
Next, open the integrated terminal from Visual Studio Code by typing CTRL+\, as suggested in the Welcome page of the editor.
There, execute:

$ dotnet new

This will create two files:




. Open the first one by clicking on it in the left sidebar, and it should contain a simple Hello World program. Probably the editor would suggest to solve some dependency; just click on Yes and wait.
For running the program, open the integrated terminal and execute:

$ dotnet run

And that’s all that is needed to start working with .NET Core and Visual Studio Code on Red Hat Enterprise Linux 7!