Getting Started with C# MonoGame in VS code

Renato Cesar
Learning C# by Developing Games
4 min readMar 22, 2021

--

If you want to run C# and MonoGame in VS code, here it is step-by-step! + Presenting my project.

This is a tutorial for Windows users, Linux version coming soon.

For Game development, why MonoGame?

Here some points:

  • The API is multi-plataform, allowing make games for Linux, Mac, Windows, Android, IOS, Nintendo Switch, X-Box, PS4 and etc.
  • MonoGame was used to create some of the best indie games, like: Celest, Fez, Stardew Valley, Tower Fall and so on (more MonoGame games here).
  • If you want to make games, why not just use Unity? Answer: I don’t just want to make games, I want to improve my planning and engineering skills while learning C#. I think the best way to do that is to create something that, in order to grow, needs to be well built and developed.
Monogame Examples

C# in VS Code

If you open the “Getting Started” documentation of MonoGame or the Microsoft .NET one you will see that they ask you to install Visual Studio and it will cost 28gb of your disc, that is not good (at least for me). However, the .NET Core and MonoGame Framework being terminal accessible, probably it is possible to run it in VS code, the most popular IDE. And as you can see, it is:

To get it running in your Windows PC you will need to install some stufs:

All those .NET drivers is to run C# code. You can find it all in the Download Section of.NET official website.

obs: Do not install the drivers and softwares for 86x bits configuration, MonoGame Doesn’t run in 86x bits, and if you install some 86x and some 64x .NET drives, it will not work.

After install everything run dotnet in your terminal to see if the environment is working properly. If doesn’t, restart your machine and try again. The command should to return:

Usage: dotnet [options]
Usage: dotnet [path-to-application]
Options:
-h|--help Display help.
--info Display .NET information.
--list-sdks Display the installed SDKs.
--list-runtimes Display the installed runtimes.
path-to-application:
The path to an application .dll file to execute.

Creating Project with .NET CLI in Terminal

First, let’s install some MonoGame required tools: (find more about it here)

dotnet tool install --global dotnet-mgcb-editor --version 3.8.0.1641

and then register it:

mgcb-editor --register

Install the MonoGame Templates, more about it here.

dotnet new --install MonoGame.Templates.CSharp::3.8.0.1641

Then create a new project from MonoGame Desktop GL template. In my case I installed the MonoGamer framework after creating the project, you can try to install it first with the next command after this one.

dotnet new mgdesktopgl -o ProjectName

obs: don’t forget to enter in your Project folder by running cd <projectName>

Now install the MonoGame framework in the project (there are some other options of MonoGame frameworks here. I Choose the DesktopGL).

dotnet add package MonoGame.Framework.DesktopGL --version 3.8.0.1641

And finally you can run the code by:

dotnet run Program.cs

Now you can program the next Terraria that will sell more than 40 million copies! If this step-by-step doesn’t work let me know in the comments, thus I can help you.

About My Project

I’m not a C# or .NET programmer, but I want to be, and to Learn this Low code language I’m planning to create, in the start, simple arcade games using the MonoGame framework.

If you want to go along with me on this journey you can follow me, and this Publication yclept Learning C# by Developing Games that will contain the documentation of the most important things that I will go through in this project. You can give me a Start in my GitHub project where all the codes will be saved. Thanks for reading, have a nice day.

You can conect with me in linkedIn too :)

--

--