Velvet Star Monitor

Standout celebrity highlights with iconic style.

news

Can I write programs in C# on Ubuntu?

Writer Andrew Henderson

I am forced to learn and practice C#, is there any applications that support and can be used to write programs in C#?

7

4 Answers

Yes you can use mono

For a nice IDE to work in try monodevelop:

sudo apt-get install monodevelop

This will also pull in all the necessary runtimes needed.

1

What you are looking for is Mono, which is, quoting from the project's website:

An open source, cross-platform, implementation of C# and the CLR that is binary compatible with Microsoft.NET

Mono also comes with an Integrated Development Environment (IDE): MonoDevelop. Both softwares are packaged for Ubuntu.

Mono

Install via the software center

MonoDevelop

Install via the software center

This last package depends on the first one. Installing this package will automatically install the other.

2

You can develop C# applications on linux with .NET Core:

After you install it, type dotnet new in your terminal to get a list of application templates which can be generated for you to start.

As of .NET Core 2.0 today, this is the list:

Templates Short Name Language Tags
--------------------------------------------------------------------------------------------------------
Console Application console [C#], F#, VB Common/Console
Class library classlib [C#], F#, VB Common/Library
Unit Test Project mstest [C#], F#, VB Test/MSTest
xUnit Test Project xunit [C#], F#, VB Test/xUnit
ASP.NET Core Empty web [C#], F# Web/Empty
ASP.NET Core Web App (Model-View-Controller) mvc [C#], F# Web/MVC
ASP.NET Core Web App razor [C#] Web/MVC/Razor Pages
ASP.NET Core with Angular angular [C#] Web/MVC/SPA
ASP.NET Core with React.js react [C#] Web/MVC/SPA
ASP.NET Core with React.js and Redux reactredux [C#] Web/MVC/SPA
ASP.NET Core Web API webapi [C#], F# Web/WebAPI
global.json file globaljson Config
Nuget Config nugetconfig Config
Web Config webconfig Config
Solution File sln Solution
Razor Page page Web/ASP.NET
MVC ViewImports viewimports Web/ASP.NET
MVC ViewStart viewstart Web/ASP.NET 

The current latest version is 2.0 and covers all my needs.

2

You could use Visual Studio Code using apt:

wget -q -O- | sudo apt-key add -
echo "deb [arch=amd64] stable main" | sudo tee /etc/apt/sources.list.d/vscode.list
sudo apt update
sudo apt install code

enter image description here

or snap:

sudo snap install code --classic

After the C# package installing, the next dialog box appears:

enter image description here

Clicking the marked button opens the next page, which provides the instructions for .Net Core SDK installation (along with ASP.Net Core runtime and .Net Core runtime installation instructions):

wget -O packages-microsoft-prod.deb
sudo apt install ./packages-microsoft-prod.deb
sudo apt-get update
sudo apt-get install apt-transport-https
sudo apt-get update
sudo apt-get install dotnet-sdk-3.1

monodevelop IDE seems is not an option now, because of I could not find it. But if you want to install the current mono version (For example, on 20.04, amd64 architecture) you could use official mono repository:

sudo apt install gnupg ca-certificates
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
echo "deb [arch=amd64] stable-focal main" | sudo tee /etc/apt/sources.list.d/mono-official-stable.list
sudo apt update
sudo apt install mono-devel

You could also install additional mono packages, which you could find by:

apt-cache search mono

The man mono will introduce you to its usage:

DESCRIPTION mono is a runtime implementation of the ECMA Common Lan‐ guage Infrastructure. This can be used to run ECMA and .NET applications.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy