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 scl 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 exit 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

Using scl 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: Program.cs and package.json. 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!

  • bell_raymond

    I have profited 104,000 thousand dollars in last twelve months by working from my house a­n­d I did it by work­ing in my own time for 3 or sometimes more h /day. I was following a money making opportunity I came across from company that i found online and I am so amazed that i made so much extra income. It’s newbie-friendly and I’m just so happy that i discovered it. This is what i did… http://urlof­.­site/TnQVc

  • [email protected]

    I was paid 104000 dollars past year by doing an internet job moreover I was able to do it by w­orking in my own time f­o­r several hours each day. I applied job opportunity I came across on the web and also I am thrilled that I was capable of to earn such decent money. It’s genuinely newbie-friendly and therefore I’m so grateful that I discovered out regarding it. Find out more about what I do… I was without work for 6 months when my early Fellow worker lastly suggested me to start off freelancing from home… That was really after I received $5000 in my first thirty days when I really believed I could do this for a living! At the moment I am delightful than ever… I work-at-home and also I am my own boss now that I always wanted… I see so many discouraged people around me, working the same old boring job that is sucking the daily life out of them day-after-day… Everytime I see anybody like that I say START FREELANCING MAN! This is how I started off >>>> www­.­cat­.­org­.­uk/snip/78276

  • [email protected]

    I was paid 104000 dollars previous 12 months by doing a web-based task as well as I was able to do it by w­orking in my own time f­o­r several hours on a daily basis. I tried job opportunity I found on the web and therefore I am delighted that I was manage to earn such decent cash. It is seriously newbie-friendly and therefore I am so grateful that I found out about it. Check out exactly what I do… www­.­cat­.­org­.­uk/snip/93439

  • lawrence_lee

    I was paid 104000 dollars last 12 months by doing an online job and I was able to do it by w­orking in my own time f­o­r several hours on a daily basis. I utilized work opportunity I found out on the internet and also I am delighted that I was capable to earn such great money. It is really newbie-friendly and I’m so grateful that I discovered out about it. Find out more about what I do… http://polr­.­me/1g1h

  • I was paid 104000 dollars previous 12 month period by doing an internet based task moreover I was able to do it by w­orking in my own time f­o­r quite a few hours during the day. I tried job opportunity I came across on-line and also I am thrilled that I was able to earn such good money. It’s seriously newbie-friendly and I’m so blessed that I discovered out regarding it. Look out for exactly what I do… http://urll­.­in/3RN3g