Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to use monogame in VS code?

I am using an iball notebook and I don't have enough memory to install Visual Studio. I am having no problems using VS code and i am able to make and create executables of my console applications. I need to learn game development but everyone keeps saying that i need to install visual studio for it

However i did find a fourm on monogame on the topic and found that it is possible(At least on Linux) to use Monogame in VS code.

http://community.monogame.net/t/visual-studio-code-and-monogame/2371

Please Help me out.I want to know if it's really possible to compile and run a monogame app in windows.

like image 307
AzuxirenLeadGuy Avatar asked Dec 17 '16 11:12

AzuxirenLeadGuy


People also ask

How do I add MonoGame to Visual Studio?

Start Visual Studio 2022 and select New Project... in the upper left corner. You should see the "Create a new project" dialog pop up. From here, select the Templates > Visual C# > MonoGame category, and then select MonoGame Cross Platform Desktop Project.

Do you need Visual Studio for MonoGame?

Before using MonoGame, you will need to install Visual Studio 2022 or later (any edition, including Community) with the following workloads, depending on your desired target platform(s): . NET desktop development (mandatory for all platforms) Mobile Development with .

What coding language does MonoGame use?

MonoGame is an open source, C# framework that implements the application programming interface (API) of XNA, Microsoft's late game development toolset that was retired in 2013. It also supports all .


2 Answers

Answer edited as Monogame released official dotnet project templates

I finally got it working.

I realized that all I needed was to create a monogame project (*.csproj) and Compile/Build it without Visual Studio. VS Code is just a feature-rich text editor and I would need other toolset for it.

MSBuild tool is used to Compile/Build monogame project and is available as a CLI. It is available without installing Visual Studio. For C# project building, dotnet core is required. executing the script

dotnet new [Template]

creates a new Project. We need to add a template for monogame here.

As per the latest update by the Monogame Team, you can install the templates by executing

dotnet new --install "MonoGame.Templates.CSharp"

Use the script

dotnet new -h

to check out all the templates available.

Now, to generate the project, use the following

dotnet new mgwindows

On successful execution, this will generate [FolderName].csproj, Game1.cs, Program.cs and other files/folders of monogame project. Please not that this csproj is on .NET Framework (version 4.5 if I'm not wrong....) and therefore it might not work with dotnet run command. (If you're a bit stubborn, you might need to copy the Monogame installed folder(which contains, among many other files, Monogame.target file) in your dotnet installed folder.)

In other words, use msbuild to build and run the project

msbuild

If the program does not contain any compile time errors, the .exe file will be built successfully and you will get to see the the Output file path which you get to execute.

If you're working on Linux or have some other reason not to use MSBuild, you should not generate a mgwindows project. You can rather chose

dotnet new desktopgl

which works on dotnet core (i.e you can use dotnet run command to execute it).

like image 61
AzuxirenLeadGuy Avatar answered Oct 04 '22 14:10

AzuxirenLeadGuy


I wrote this (Windows-only) solution in medium. It's a step-by-step of how to install and run dotnet with MonoGame in the terminal of VSCode.

You need to install:

  • .NET SDK 5.0
  • .NET Core SDK 3.1
  • .NET Runtime 5.0

You can run dotnet in your terminal and see if it's working.

  1. Install MonoGame editor:

    dotnet tool install --global dotnet-mgcb-editor
    

    and

    mgcb-editor --register
    
  2. Install MonoGame Templates:

    dotnet new --install MonoGame.Templates.CSharp
    
  3. Create a new project in the chosen template:

    dotnet new mgdesktopgl -o ProjectName
    
  4. Enter in your project with cd ProjectName and add the MonoGame package to it:

    dotnet add package MonoGame.Framework.DesktopGL --version 3.8.0.1641
    
  5. And finally:

    dotnet run Program.cs
    
like image 40
Renato Avatar answered Oct 04 '22 16:10

Renato