Current State of Windows/Linux Solution

About a year ago, I asked if it was possible to create a single code-base that builds both Windows and Linux games with MonoGame.

The answer was “sort of”:

  • Protobuild works, but I want “vanilla” MonoGame
  • Creating two solutions and sharing (Add as Reference) code works, but it’s tedious
  • MonoGame portable something works, but the NuGet package seems deprecated.

TLDR: Can I create, today, one solution that builds both Windows and Linux versions of my game, ideally with a shared/common “core game code” project?

(LibGDX allows something similar in the Java world.)

You can start out with a DesktopGL template. The executable that’s built can run on Windows, Linux and Mac (you need mono for Linux/Mac). You don’t even need seperate projects! If you want the game to run on DX on Windows, go with PCL or shared project. Just reference the correct assembly in you platform specific projects so that one is used. There’s been some talk on GitHub on reintroducing the NuGet PCL assembly and on a project generation tool (1) (2) that can help you get set up with this, but there hasn’t been a lot of movement in that lately.

No, you just build it once in either VS or MD and the executable should run in both Windows and Linux (with mono) :smiley:

How exactly does that work? What exactly is the executable generated?

The executable is a .NET assembly. It has a .exe extension on Windows and knows that it has to be run though the CLR. The same .exe file can be executed using the mono CLR on Mac and Linux.

Ah, sorry, I don’t have much experience with Mono. I forgot that it runs with the mono command (I keep thinking Linux requires a different set of binaries).