Setting up C# development environment in Linux

Recently I got curious in  .Net development on Linux environment.

I am aware of the Mono Project, but wanted to keep it as "pure" as it could be, meaning that I wanted to be, as much as possible, a Microsoft development environment.

I'm a long time Kubuntu user when it comes to Linux desktop, and I'm also a Visual Studio Code user for quite sometime.

 

.Net SDK

Starting with the basics, and already having VS Code installed, I started by installing .Net (Kubuntu is not mentions, just use Ubuntu as the reference) simply using 

sudo apt update
sudo apt install -y dotnet-sdk-7.0

That pretty much takes care of having .Net SDK installed.


VS Code IDE

Next step was to set up VS Code as the IDE.
This was achieved by installing the following VS Code extensions:

As a hint, pressing CTRL+SHIF+X on VS Code and searching for ms-dotnettools  on the extensions marketplace will list a lot of useful things.


Hello World

Once the basic was in place, it was time to try it out.
On a terminal, I typed the following commands to set up a Hello World console application:

mkdir HelloWorld
cd HelloWorld
dotnet new console

And a new console application was created printing "Hello, World!" into the terminal.
As a hint, type "dotnet help" for a list of available commands. Try also "dotnet new list" for a list of available templates.

Open the HelloWorld folder with VS Code, CTRL+K CTRL+O, and you can see generated code in the Program.cs file.

To build and run the application, just press CTRL+SHIFT+D and you'll be on the Run and Debug menu options. Having the ".Net Core Launch (console)" option selected and using "Start Debugging (F5)" will bring up the Debug Console and you'll be able to see the application execution.


Bonus | Desktop and Game Development

Don't get disappointed because it is not possible to develop desktop applications using Forms in Linux using C#.
It is possible to develop cross-platform games for desktop, or other kind of graphical applications, using SDL2 and OpenGL.
For that, and as Microsoft refers, it is possible to use MonoGame, just check the DesktopGL, template mgdesktopgl.
Keep in mind that packaging  and distribution is available, start coding and have fun.

To package and distribute, you can .

./M6