MonoGame porting to linux - c#

I have developed a game on Windows 7 (64bit) in Visual Studio 2015 with the language C# and the MonoGame framework. The game works fine on Windows, but I also wanted to make the game to be playable on Linux. Therefore I installed VirtualBox with Ubuntu 15.10 (64bit) on my Windows PC, to test if I can make my game running on Ubuntu.
After trying to compile the game in different ways with no solution in sight, I came to the conclusion to ask a few questions here about deploying MonoGame to Linux:
Is it possible to compile a MonoGame game in VisualStudio 2015 on Windows for Linux in a...
1.1. MonoGame Linux Project?
1.2. MonoGame Windows OpenGL Project?
1.3. MonoGame Windows Project? (which my game currently is)
If [1.] what are the requirements and what programs need to be installed on Linux to run this [1.x] build?
Is it possible (and recommended) to compile the game in MonoDevelop on a virtual Ubuntu machine?
Is it even possible to run a MonoGame game on a virtual Ubuntu machine?
What is the proper executable file extension for a game on Linux? (Because Linux Project on Windows is only building a .exe)
I have almost no experience with Linux, so I hope someone can answer me these questions, maybe someone who has experience with porting a MonoGame game to linux.
Thanks.

Though the question is a few years old, it's deserving of an answer. I managed to make cross-platform builds for a game built in MonoGame through Mono's mkbundle. Here is a great tutorial for doing so on Windows.
You'll want to download the latest Mono version and append an "exe" extension to the file located at C:\Program Files (x86)\mono\bin\mono. Next download the appropriate runtime for the platform you want to deploy to, give it a "zip" extension, and extract it into the following path: C:\Users\youruserhere\Documents.mono\targets
After that, you should be ready to build; open up a Command Prompt and enter mkbundle --local-targets. If everything went smoothly, the runtimes you have installed should be displayed. After that is a matter of building an exe to the target platform.
Here's an example for building an application to Ubuntu: mkbundle HelloWorldConsole.exe --simple -o HelloWorldBundleUbuntu --cross mono-5.10.0-ubuntu-16.04-x64
Keep in mind that some classes not implemented in Mono, such as WebBrowser, will cause the build to fail. If this is the case, you may need to find a workaround.
With this you can run the file in Linux by entering ./HelloWorldBundleUbuntu in a Terminal. I've had no issues running the game this way in a virtual machine.
Lastly, if you want to go the .NET Core route, MonoGame has a WIP core fork that you can use, though I'm unsure how well it works.

To add to an already year old answer by Kimimaru, there's also the possibility to use MonoKickstart to get your Monogame executables up and running on Mac and Linux without the need to bundle anything. This is especially handy if your projects are a little difficult to bundle, because of third-party libraries or otherwise.
You simply unpack the Kickstart archive and paste your Windows executable ontop. By editing the .kick files to point to the appropriate executable, they will act as an intermediary to run your programs using mono (which is provided, as well, no need to install on target machine).
https://github.com/mrhelmut/MonoKickstart

Related

How to run Mono application on Windows properly?

I am completely new to Mono and Gtk#. I'm developing an app on Linux but I want to run it on Windows as well. However, if I build the app using MonoDevelop and then run the .exe file in Windows, it doesn't launch.
Is it really possible to make Windows apps using Linux/Mono, or am I missing something?
Baltasarq is correct. The reason that your app won't run is that the dependent GTK# binaries are not on your target machine. The compiled .exe will run on any .NET implementation so long as it is of at least the .NET version that your executable targets and the dependent assemblies are available.
Like Symon said, you have to build your project on the operating system you're intending it to be be compiled for because of the resources (API's etc.) that specific operating system is loaded with.
When I have a problem like this, I simply use a virtual machine software like VirtualBox or VMware to run Windows and then install and run MonoDevelop inside of Windows. Don't worry about the expensive cost of Windows, for you can just get Windows from Microsoft's website here. There will be a little watermark in the corner of the screen because you didn't pay for the copy, but everything is still totally legal and fit for software development.
UPDATE:
A better method to do this is to install the GTK# dependencies and then recompile the program.

How do I compile a C# application on a Mac in Visual Studio?

Basically, my school only has Mac computers, however they're telling me to learn C# and to do so using Visual Studio. However, the school program is fairly new and the projects are self-guided. I've been coding in C# using Visual Studio and it's been working so far - it's run successfully and everything. However, I can't seem to find a way to export or publish my code into a standalone application. I've tried using WineBottler to convert the .exe into a .dmg, but I can't seem to make it work.
How should I do this? Moving to Windows or another IDE/compiler isn't an option. I've currently been creating my projects in a Console App, but I could change that if necessary.
After quite a bit of experimentation and research, I've found that while you can publish a .NET Core Console App within Visual Studio for Mac, the feature is not supported within the GUI of the program (for whatever reason).
In order to publish, you have to Control-Click on the solution in the Solution Explorer and open the project in the command line by clicking Tools > Open In Terminal.
Once there, type in the command:
dotnet publish -c Release --framework netcoreapp2.1 --runtime osx-x64
This will create a self-contained program for 64-bit mac os on the v2.1 .NET Core framework. The runtime can be changed for different operating systems and the version number for netcoreapp can be changed based on which version you're using and what is compatible with any plugins for your program.
The final product will be found in yourprojectfolder/yourprojectname/bin/Release/netcoreapp2.1/osx-x64/publish
You should have no issues creating and compiling .NET CORE console apps using a Mac. These apps will have limited .NET functionality, do not have .exe files, and are platform agnostic. Here is a quick guide you can reference to decide if .NET CORE is the right option for you.
If you are trying to create WinForm apps or something similar, you cannot do this on a Mac. There are "work arounds" using Wine or other tools, but my experience with those options has been suboptimal at best. If you need to create apps like this, then your best option is to program on a Windows machine. Perhaps ask your school to enable bootcamp and install Windows 10 OS on one of the Mac machines.
You can generate exe using the terminal if you are on OSX. You can follow this post
It requires :
Visual Studio For Mac
A .cs file
Few lines in terminal

Porting from Windows to Mac

I have a program on .NET 4 for Windows. I'm trying to port it for Mac computers with mono and Xamarin studio.
I use this code for building:
macpack -m:1 -o:. -r:/Library/Frameworks/Mono.framework/Versions/Current/lib/ -r:/Library/Python/2.7/site-packages/emgucv/lib -r:/Library/Python/2.7/site-packages/emgucv/bin -r:Assimp32.dll -r:Assimp64.dll -r:cvextern.dll -r:Emgu.CV.dll -r:Emgu.Util.dll -r:libegl.dll -r:libglesv2.dll -r:OpenTK.dll -r:OpenTK.GLControl.dll -r:RH.ImageListView.dll -r:blending.fs -r:blending.vs -r:blendingPl.vs -r:idle.fs -r:idle.vs -r:skelet.vs -r:sprite.png -r:./Libraries -r:./Models -r:./Plugin -r:./Resources -r:./Stages -r:./"Haar Cascades" -n:HeadShop -a:RH.MyProgram.exe
where I attach mono lib, emgucv lib and all my dll's from debug folder..
All works good on my machine (where I have mono, xamarin studio and all libs installed), but on a client machine - program doesn't run. It doesn't give any errors, just doesn't appear..
Should user install mono or something else for launch program or my command for building is wrong?
I guess you have to install at least the Mono Runtime. Since it seems not possible to install it alone, you may have to install the Mono Mac Package.
However, since mono translate C# code into Common Intermediate Language you have to install at least something that can interpret that code and translate/run it on the CPU - An installation is needed in any case.

Run XNA 4.0 game on other machines

I checked here: How do I get an XNA 4.0 game to run on other machines?, but there's no real solution in it.
I created a completely empty XNA4.0 project, selected Release and compiled it, rar'd up the Release folder and sent it to a non-development PC. Got an Appcrash generic error.
Its probably something standard I'm doing wrong, but no idea what..
Can confirm that both .NET4.0, XNA Redist 4.0 and DirectX are installed on the other machine.
UPDATE: The empty 'new game' loads now, but I have made a program or six over the last years, each of which doesn't run on the other machine. Could someone perhaps link me to 'proper' referencing, assemblies, and such? Google dropped those words more than once in combination with my problem.
UPDATE: I asked a friend to test on his PC, at first, same error, but he forgot to install the XNA 4.0 redist. After that, my files were running fine on his pc. Still, they're not working on my own non-development machine, for some reason. Anyway, thanks for the suggestions, now that I know its local I can probably fix it myself. Suggestions are still welcome.
The end-user needs to have .NET 4.0, the XNA 4.0 Redistributable (not the full game studio), and DirectX installed.
Is there the Dot-Net 4.0 and XNA 4.0 framework installed?
Choose to publish the project and you will get an installer that check and install required libraries for you...

Compiling moonlight application on Mac OS X

I'm using MonoDevelop 2.8.5 and I'm trying to compile a moonlight application, but it fails. I created a brand new Moonlight Application Project and tried to compile it, but it fails with the following error.
Error: Framework 'Moonlight / Silverlight 4.0' not installed. (MoonlightTest)
In this question from October 2011 one of the developers of MonoDevelop states that is not possible to do this without some major hassle.
Is this still true with the new version(s) of MonoDevelop out?
If so, how can I compile Moonlight Application Projects in MonoDevelop if I'm willing to go through some hassle?
This is a bit of "psychic debugging" but I've run into it a lot in linux and imagine you might have the same problem happening on OS X. Is the compiler that Monodevelop is looking for exactly the same as the version you installed? It might be something as simple as the folder being called Moonlight1.3 vs Moonlight1.3.1. Look at the build output and see what version it is looking for then look in your applications folder (via terminal the app folder in the finder might hide the info) and check that they are the same.

Categories