I recently started using Monogame for the first time because of it's cross platform compatibilities and heavily active development. The first thing I did is installing the whole framework using their provided installer, but as soon as I wanted to make my first Monogame project, I noticed the following:
Although being cross-platform, there is no real 'Monogame' library. The framework ships with multiple assemblies for several platforms, each with their own dependencies. This is reflected both in the Visual Studio project templates as well as for the nugets they provide.
Now I'm wondering: Is there a straightforward way to just develop with the Monogame framework 'itself' in the first place, and then deciding on platform etc. later by using build targets and conditional compilation? Or do I just have to reference every assembly and it will work out of the box? What's your approach when developing with Monogame for different platforms? Making a .NET project for every target platform?
Their documentation unfortunately doesn't describe the different platform assemblies. They are just there, ready to be used with the infomation that Monogame IS cross-platform compatible.
Monogame game is cross-platform compatible, but not in the sense that you just magically click and it will work. In most cases, you are going to need to tweak individual builds, in order to get them to function properly in each environment.
If you consider supporting iOS or Android, you are going to have to look into the xamarin dependencies as well, which are not even part of the Monogame framework at all.
Fortunately, most of the code will just work. It is a matter of getting the builds to compile and work as intended on each environment. There will almost always be at least some minor issues, you will need to compile and try it for each supported environment.
In Monogame, the source code of your game is the only thing that is identical for every platform. Of course you would have to change how you handle inputs for every platform (for example windows doesn't have touch) and how you calculate the screen size (mobile doesn't have multi-monitor setups). If you chose to use the
#IF __ANDROID__ and
#IF WINDOWS keywords in your code and inside your visual studio project, then you will basically have a common source code folder and you will be able to copy paste it between projects to bring them up to date.
Typically, the best way of developing games is to first develop it for windows Desktop and then when you are finished developing your game, spend a couple of minutes making an Android (or any other) project and setting it up. This is because Desktop projects compile so much faster.
There is no reason to worry about multi-platform until the moment you are ready to deploy your game. Note that you will need a 25$ license from Xamarin to compile your game for Android/iOS. That license lasts for 1 month, but you actually only need it just for the few seconds that it takes to compile (if you are not planning on adding content to your game and having to re-compile at least). The free trial version of Xamarin only produces
.apk (and the equivalent for iOS) which last for 24-hours.
As for the dependencies, here is how my project looks like when I build from Monogame's source code. Windows DirectX (on the left) and Android (on the right). Its pretty straight forward.
SharpDX.dll(s) for windows. And
OpenTK.dll for Android. You would be able to compile these 2 projects without having anything Monogame related installed. Because I reference the dlls such as
SharpDX.dll locally (I have placed them in a SharpDX/ folder inside my Monogame.Framework.Windows library-project).