Which is the better option for running C# programs in Ubuntu?

  • using Mono and compiling in the terminal
  • Microsoft Visual Studio Code
  • Microsoft .NET SDK.

closed as primarily opinion-based by muru, George Udosen, Eric Carvalho, Charles Green, David Foerster Dec 16 '17 at 16:33

Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise. If this question can be reworded to fit the rules in the help center, please edit the question.

  • Just running or developing? – Melebius Nov 20 '18 at 9:59

The terminal and MonoDevelop (monodevelop) from the default Ubuntu repositories is maybe all you need, and Visual Studio Code doesn't live up to its full potential until you install lots of software to go with it. It's amazing how fast Visual Studio Code can chew up a gigabyte of disk space when it turns your Ubuntu into a Windows development environment.

If you don't stop there you need to grant root access to some fancy development software to keep going. Visual Studio Code treats every platform as if it's Windows, so sometimes the extra software you installed doesn't work. Visual Studio Code doesn't warn you about this, so you need to install the software in order to find out if it works or not. Finally you have a Microsoft epiphany moment when you realize that Visual Studio Code is a fancy code editor, not an IDE, and you need to buy the latest version of Windows and install Visual Studio in it. All this is optional, so in Ubuntu 17.10 and earlier you're better off starting with the lightweight MonoDevelop IDE and see how it goes.

MonoDevelop can be installed from the default Ubuntu repositories in Ubuntu 17.10 and earlier. This link tells how to run C# programs from the terminal and in MonoDevelop: How do I install Mono for 17.10?

The wonderful C# is open source and cross platform now that Microsoft has released a version of .NET Core, and it's blazingly fast. To install .NET Core in Ubuntu follow these steps which are also listed below for Ubuntu 16.04. Visit the link for installation instructions for other Ubuntu versions.

Register Microsoft key and feed

To start installing .NET, you'll need to register the Microsoft signature key and add the Microsoft Product feed. This only needs to be done once per machine.

Open a command prompt and run the following commands:

curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.gpg
sudo mv microsoft.gpg /etc/apt/trusted.gpg.d/microsoft.gpg
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'  

Install .NET SDK

Update the products available for installation, then install the .NET SDK.

In your command prompt, run the following commands:

sudo apt install apt-transport-https
sudo apt update
sudo apt install dotnet-sdk-2.1.103

Ubuntu 18.04

Before installing .NET, you'll need to register the Microsoft key, register the product repository, and install required dependencies. This only needs to be done once per machine.

Open a command prompt and run the following commands:

wget -qO- https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.asc.gpg
sudo mv microsoft.asc.gpg /etc/apt/trusted.gpg.d/
wget -q https://packages.microsoft.com/config/ubuntu/18.04/prod.list 
sudo mv prod.list /etc/apt/sources.list.d/microsoft-prod.list
sudo chown root:root /etc/apt/trusted.gpg.d/microsoft.asc.gpg
sudo chown root:root /etc/apt/sources.list.d/microsoft-prod.list  

Update the products available for installation, then install the .NET SDK.

sudo apt-get install apt-transport-https
sudo apt-get update
sudo apt-get install dotnet-sdk-2.1

Not the answer you're looking for? Browse other questions tagged or ask your own question.