Creating a new monogame proyect

I’m completely new to monogame, and, to be honest, I’ve never created a new #C project, only worked on existing ones, which brings me to the question:

How do I create a new project

A lot of guides say download this IDE, or that IDE and then pick File> New Project.
Honestly, I’m not interested in switching IDEs, all I need to know really is how to create a new project.

Yes, I’ve checked the man pages for xbuild, mono, and mcs, but they don’t seem to have any useful pointers.

I’ll add it to the list for my MonoGame YouTube Channel.

However as an initial “getting started” you can try this video in the collection - https://www.youtube.com/watch?v=WonVmlpPBuU

Also, check the old XNA “getting started” tutorials, swapping wherever they say XNA for MonoGame.
http://xbox.create.msdn.com/en-us/education/gamedevelopment

First install MonoGame on your machine, downloading it from the downloads page from http://MonoGame.Rocks.
Use Visual Studio Community (it’s free) if you are on a Windows machine or Xamarin Studio if you are on a MAC.

Then creating a new project is as simple as “New Project -> MonoGame -> MonoGame Template” and then start coding.
A basic game class is provided by default to get you started.

Hope this helps

Linux

Check post tag :slight_smile:

1 Like

Like I said (this seems to have been completely ignored), I’m really not interested in switching IDEs right now.

All I’m really asking is how to create a new project (via cli, probably), since I have almost everything else covered.

This is a bit difficult atm. There are plans for a cross-platform project generation tool that can generate all kinds of MG projects. It will also be used by the plugins for MonoDevelop and Visual Studio so they don’t all have to be maintained seperately. It’s kind of a pain, but the easiest way for now to set up a project on Linux is by installing MonoDevelop before MonoGame and creating one from the template. Of course you can just program and build in any environment you want once you have the project in place.

I’m not sure how far done it is or if it will work at all on Linux at this point, but the PR from @hachque that implements the tool is at https://github.com/MonoGame/MonoGame/pull/4295

EDIT: Updated instructions for a Linux host machine instead of Windows - Protobuild and the Protobuild Manager work on all desktop platforms.

For the CLI way of doing things:

  1. Download Protobuild.exe from https://protobuild.org/get and put that in a folder where you want to store your project.
  2. Open the command line and type mono Protobuild.exe --start https://protobuild.org/MonoGame/Template.2DPlatformer@develop
  3. Wait for it to finish
  4. You can now open your Project.Linux.sln project - it will target your host platform by default.
  5. Open the Project.Linux.sln file.
  6. Done

The GUI way of doing things:

  1. Follow the instructions on https://protobuild.org/ to install for Linux
  2. Run the Protobuild Manager after it finishes installing
  3. Click “Create New Project” (these screenshots are from Windows, but the interface is the same for Linux):
  4. Pick the 2D platformer template:
  5. Fill in the project details:
  6. Click “Create Project”. Once the project has finished creating, you can then open it in your IDE.
  7. You’re done.

If you have any trouble, please let me know.

2 Likes

For @Jjagg, @SimonDarksideJ and anyone else reading this topic:

The project generator tool is already completed and implemented, and is used right now for Protobuild itself to offer users a bunch of templates to start with (including one for MonoGame). This lets users create projects for any platform, as well as opt-out of Protobuild (they can pick the platforms they want generated if they just want C# projects).

To install the tool for your platform, just visit https://protobuild.org/ and click the big download link. You can also just place Protobuild.exe in an empty folder and double click it (or run mono Protobuild.exe) and it will automatically install and run the Protobuild Manager for you.

1 Like

So it just needs some branding to be accepted into the MG repo or are there other things that should be resolved?

There’s nothing left to be resolved on my list as far as I’m aware - someone with the permissions to merge it in just needs to review it and merge it.

The differences between the PR and using the tool installed from the Protobuild website are:

  • Branding - the PR version has a branding file which themes it for MonoGame
  • Uses templates specified in the MonoGame repository - The official Protobuild Manager uses templates from the Protobuild index
  • Some of those templates in the MG repo have more options (like using shared projects, picking DirectX / OpenGL for Windows platform, etc)

Oh, awesome. I thought there was a good reason there was so little action regarding this for the past months, but I guess not :stuck_out_tongue: I’ll test it out this weekend if I can find the time!

EDIT: the branch needs rebasing, fixing conflicts might be a pain :frowning:

Thanks. These instructions seem to have worked, but with one catch - it downloaded and incredibly massive amount of data onto my drive (1.4GiB!!):

  • 326MiB in ~/.config (it’s probably not config files though).
  • 1.1GiB in the current directory:
28K     Build
890M    MonoGame
1.5M    game
214M    game.Content
8.0K    game.Linux.sln
4.0K    game.Linux.speccache
184K    get

This happened even though monogame was already installed, but after attempting to delete the directory MonoGame, xbuild fails (it looks like the directory has the source for MonoGame itself).

Should I maybe use some flag or did I miss something? I don’t think I’d need the source for MonoGame itself, especially on every new project.

MonoGame doesn’t currently provide binary Protobuild packages (that was https://github.com/MonoGame/MonoGame/issues/3126), so Protobuild has to download the source code.

I’d like to see binary Protobuild packages provided for MonoGame, but as it stands I don’t think there’s much chance of that happening upstream unless there’s a push from users to see it.

If you want to use the same version of MonoGame for every project on your system, you can do this:

  1. Clone MonoGame’s repository somewhere on your computer.
  2. Edit or create the file “~/.config/protobuild-redirects.txt” and add the following content to it. (For Windows users, the path to this file is “%appdata%\protobuild-redirects.txt”)
    http://protobuild.org/MonoGame/MonoGame -> local-pointer:///home/path/where/you/cloned
    
  3. Run the --start command again, or delete the MonoGame folder and then run --generate.

All new projects will use the cloned folder. When you want to update MonoGame, just do git pull in the cloned version of MonoGame.

Because you’re using local-pointer in the redirect file, Protobuild will not make a copy of MonoGame for your project - that means if you change or patch source files for MonoGame when you have your solution open, that will be changing the files in the location you actually cloned to.

I should also note that the download is cached - If you were to run --start again you’ll see that it updates a Git repository in the cache and then clones from the cache, rather than re-downloading the content again. Even when upstream makes changes, Protobuild will just run git fetch in the cache so that it never needs to redownload the data again.

Since the issue here lies in protobuild and how it managed the MonoGame dependency, Is there any way to create a new project via cli without protobuild? Or use the already-installed binary system one?

I really don’t want to fall back to manually tracking installed libraries, especially having a really huge amount of source lying around.

I mean, it’s clear that the source itself is not required, since I can build projects generated elsewhere without any additional downloads.

Protobuild isn’t aware of the system installed MonoGame libraries - those system installed MonoGame libraries are designed to be used with the IDE and projects created via the IDE. They’re completely separate from the dependency system that Protobuild uses.

You don’t need to manually track or manage any installed libraries with Protobuild. To update MonoGame in the project that was created, just run mono Protobuild.exe --upgrade-all and it will automatically update all the dependencies of your project.

I can’t give any suggestions on how to create projects outside Protobuild - I don’t use installers or anything like that for my projects.