4

I've been trying to figure out on how to setup a Cross-Platform project for MonoGame. Whats the conventional way of doing so ? Is that done through a Shared Project and can I keep all my content in 1 project ?

Also I am not sure if this information is correct do I need a Mac to build my project for Mac how does that work ? If so how what's the best way of setting that up.

Targeted Platforms : WINDOWS, LINUX, MAC

2 Answers 2

4

The best way to setup a cross platform MonoGame project IMO would be to use a Shared project. Shared projects can also include .mgcb file so you won't need to duplicate your content either. How to do:

  1. Use "Xamarin Studio/MonoDevelop" and create a "MonoGame Shared Project" with the name of your game
    • If you are going to use using "Visual Studio", close the "Xamarin Studio/MonoDevelop" after this, and open up the created project vith it
    • you are gonna have to include the generated "Content\Content.mgcb" file with build action "None" so it will be visible in Project View area
  2. Add a MonoGame Project for the platform you wish to launch the game from, ie. create a "MonoGame Crossplatform Project" and name it "(gamename).DesktopGL"
  3. Delete "Game1.cs" and "Content Folder" from the Platform project
  4. Add a reference for your Shared project
  5. For your platform project, in options set the Output Assembly Name to be the same as your shared project
    • this step might not seem important, but if you are using a custom importer/processor this will allow you to not have to compile the content separately for each platform.

There you go, you should be able to run your project now.

Also I am not sure if this information is correct do I need a Mac to build my project for Mac how does that work ? If so how what's the best way of setting that up.

The created executable from DesktopGL project is runnable on Mac even when compiled from Windows, the Mac user just has to launch it using Mono. In case you want you can package your game using MonoKickstart so that your Linux and Mac users don't have to have mono installed: https://github.com/MonoGame/MonoKickstart what's more, it also includes other needed native libraries. Description on how to use it are in the link.

1

Since you're just targeting Windows, Linux and Mac, you can use Xamarin/MonoDevlop which runs on all three of your target platforms.

Once it's installed, then add the Monogame through the Addin manager. The addin on version 5 of Xaramin and MonoDevlop.

You can then use the same Solution project file between all three platforms assuming you use the OpenGL Template. I use this method for developing between Windows and Linux.

The only time you'll need to use a shared project or something similar would be if you started developing for Mobile (iOS/Android) or for Windows on DirectX instead of OpenGL.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.