Skip to content

Instructions on how to build your MonoGame Game for Linux.

Notifications You must be signed in to change notification settings

owlxof/PackagingMonoGameForLinux

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 

Repository files navigation

How to package your game for Linux

(By Linux I am of course referring to GNU/Linux)

Releasing your game for Linux is super hard, right? Well, if you have a standard MonoGame setup and happen to be using Desktop OpenGL for rendering your graphics, you're in luck.

Assuming you already have your development environment setup for targeting Desktop OpenGL, all it takes are three super easy steps:

1 - Build your game

As described in the monogame documentation, the command for building a Linux standalone is this:

dotnet publish -c Release -r linux-x64 /p:PublishReadyToRun=false /p:TieredCompilation=false --self-contained

Note that no command in this guide needs administrator or superuser privileges, so you should not execute them as root or administrator.

The command is the same on any operating system. It does of course require you to have the .NET SDK installed, which you already have if you are able to build a release for Windows. If not, the MonoGame documentation has the details.

2 - Check if your game runs on Linux.

Running the build from the Linux commandline:

./relative/path/to/YourGame/bin/Release/netcoreapp3.1/linux-x64/publish/YourGame

or:

/full/path/to/YourGame/bin/Release/netcoreapp3.1/linux-x64/publish/YourGame

Your game should start as normal. In case you get an error, see below in the troubleshooting section.

3 - Archive it as tar.gz

It is recommended to distribute your game as a tar.gz archive as this preserves file permissions.

Linux / Mac:

The CLI command for creating a tar.gz archive is:

tar -czvf [[filename.tar.gz]] directory

So for your game this would look somewhat like this:

tar -czvf YourGameName.tar.gz YourGame/bin/Release/netcoreapp3.1/linux-x64/publish

Source for Linux, tested on Arch Linux.

Source for Mac

See also the man page of tar.

Windows:

  • Use 7zip or tar to create a *.tar file out of the folder YourGame\bin\Release\netcoreapp3.1\linux-x64\publish
  • Use 7zip or gzip to turn the *.tar into a *.tar.gz file.

Source

Done

Told you - super easy. What, you encountered problems? Let me know!

You can now distribute your YourGame.tar.gz archive as a Linux release in exactly the same way as the .zip for Windows release.

How users can run your game

To run your game, your customers can simply run the following two commands:

tar -xzvf YourGameName.tar.gz
./publish/YourGameName

Of course, if you rename the publish folder to the name of your game before archiving it, that changes the latter command into something a bit more presentable.

You may also want to look into enhancing your release with a .desktop file to allow distros to display your game with desktop menu icons etc.

How to create desktop entries blog post

ArchWiki on desktop entries

Troubleshooting

You may run into the following error when trying to run your Linux build:

Process terminated. Couldn't find a valid ICU package installed on the system. Set the configuration flag System.Globalization.Invariant to true if you want to run with no globalization support.
   [...]

The easy fix is adding the following property to your YourGameName.csproj file, before building your game again.

<PropertyGroup>
    <InvariantGlobalization>true</InvariantGlobalization>
</PropertyGroup>

Source for this fix, that I tested on Arch Linux.

About

Instructions on how to build your MonoGame Game for Linux.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published