radimitrov / CSharpShellApp

77 stars 18 forks source link

Monogame support? #318

Open KUNGERMOoN opened 9 months ago

KUNGERMOoN commented 9 months ago

Would it be possible to add support for MonoGame projects? According to the MonoGame's documentation for android it uses Xamarin.Android (which, as far as I know, is supported by this app) with this template. I actually tried to import said template in the app, but got an exception: System.Exception: Error: Specified entry point or Main method not found - at CSharpShellCore.Common.CSharpShellExtensions.InvokeEntryPoint(Assembly asm, String entryPoint, String arguments, Stopwatch stopwatch) at CSharpShellCore.Activities.MainActivity.<>c__DisplayClass241_0.<Run>b__10() and adding some kind of official support for it would be really cool. (Note: it required to reference Mono.Android - to use Android namespace, and remove reference to nuget "MonoGame.Content.Builder.Task" - for reasons explained below)

What might cause some problems, is MonoGame's Content Pipeline. First, the developer should use the MGCB Editor to reference the textures, effects, audio, 3d models and sounds they want to use in game and select to which platform they want to build the assets. Then when the game is being compiled Monogame Content Pipeline's MSBuild task (distributed as "MonoGame.Content.Builder.Task" nuget, by default referenced by every MonoGame project) executes the actual compression and conversion of the assets (however it is also possible to do it using said MGCB Editor whenever you want). The problem is that:

  1. MSBuild is not supported by this app, as far as I know
  2. The actual compression code has a bunch of native dependencies - some of them are even closed-source and their developers don't provide ARM-compiled DLLs. Is should be possible, however, to port the tool by compiling open-source dependencies for ARM and finding replacements for the closed-source ones (I actually tried to port the Content Pipeline for all platforms supported by MonoGame for runtime usage, but it seems like I don't have enough experience with both Content Pipeline and cross-compiling C++ libraries, so that's a project for another day)

This solution is, obviously out of the scope for this app. However, it is entirely possible to compress the assets on pc and copy them to android device. Also, the Content Pipeline is not required to load assets in MonoGame - it is entirely possible (however not as performant - Content Pipeline exists for a reason) to use functions like Texture2D.FromStream to load assets at runtime - and it's actually preferred by some developers over fighting with the messy Pipeline.

So I think that the content Pipeline could be just ignored, if the support for MonoGame in this app would ever get added. After all, no one demands this app to support an entire big, desktop-based game development framework - and adding something very basic for it would already mean a world for me.

radimitrov commented 8 months ago

It should be possible to implement good but not complete support. For example, probably no building MonoGame apps. I'm not 100% familiar with the MonoGame to guarantee support for it will be implemented, support for other might be needed (I think it doesn't need Java at least). Can't start working on it anytime soon, however it would likely be a downloadable/on-demand module.

Quimby64 commented 8 months ago

"it would likely be a downloadable/on-demand module." Where would be the best place to subscribe to hear about this module if it gets released? I would be all over this update as it would greatly extend the functionality of this already excellent app. The content builder limitations would be a pain, but as KUNGERMOON said, it's not important as those assets could be processed on pc and then copied onto the phone.

radimitrov commented 8 months ago

As far as I can remember there are a few issue threads about MonoGame. When or if it is implemented I will simply close them all as completed