I’ve been playing around with MonoGame for a few days, but I’ve worked with C# for much longer. One thing I’d like to do is make a cross-platform library that I could share across all platform-specific specific MonoGame projects. I’ve been searching for answers on that, but many results were pretty old and don’t take into account new projects.
Generally, the minimum would be a project that would allow me to share various structures and elementary logic across projects. Ability to use common MonoGame classes such as Game (from MonoGame.Portable, maybe?) would be a bonus. If some classes would not be available, I guess I could work it around with interfaces and/or generics where needed, and supply implementations in platform-specific libraries?
I have installed MonoGame 3.6, and use it with Visual Studio Community 2017. I also installed the mobile development workflow, with all its Xamarin-related dependencies.
So far, to me, the most viable candidates seem to be Class Library (Legacy Portable) and Class Library (.NET Standard). I can’t find any other project template that seems “cross-platform,” but maybe I’m missing something.
Which options would you recommend? Thank you in advance. ^^
Class Library (Legacy Portable) will disappear at some point and can be considered obsolete.
.NET Standard should be the one used, unfortunately this cannot reference Monogame which is a regular .Net Framework project.
The only option left would be Shared Project, but in practice you’ll loose intellisence, not practical at all.
Currently, you won’t get a cross platform setup, not until Monogame moves to .NET Standard itself.
I guess I’ll opt for .NET Standard + MonoGame-related interfaces, and the platform-specific implementations using MonoGame classes; hopefully, the latter shouldn’t require frequent changes, even if the base library has some internal changes.
Is there any update on MG supporting .NET Standard? I am faced with the same challenge of needing to use a shared library across Android, OpenGL and UWP. It’s currently a shared project, but I need it as a PCL / library in order to leverage internal / assembly accessibility.
This might sound hacky (especially from another newbie to MonoGame) - but I’ve found a possible work-around, that seems to work under Android emulation, as well as cross-platform desktop.
Create a mono-game content pipeline extension project.
Delete out the default template code.
Treat the project as if it were a portable class library!
This seems to work for me.
With regards to the .NET Standard project - I tried this, and added it as a project reference, and also had code (because I’m experimenting) in a Shared project. From the shared project, I referenced a type in the .NET Standard project, and Visual Studio seemed happy to allow that. However, when I build the project, it failed. Perhaps an issue on my side. But regardless, the hi-jacking of the ContentPipelineExtension project worked for me more than once:-)