MonoGame UAP for Universal Windows Platform (Windows 10 Build 10240)

THE GAME BEGINS

Recently I updated my Windows 10 to the latest Build 10240 and I wanted to create my own game framework leveraging the powerful Win2D which is open source from Microsoft and I was thinking, hmm… why not find see the existing game framework first. And yes, it remind me to my experience using XNA which is, well “not available” anymore. So I turn to MonoGame, yes… one of the best open source game framework. And so I did, I download the latest MonoGame 3.4.

Perfect! right… By the way, I’m using Visual Studio 2015 (Enterprise), you can also install MonoGame 3.4 for Visual Studio Community 2015 which is free for developers. Once, installed, I directly see the Project Templates ( yay! very excited ).

MonoGame 3.4 Windows 10 UAP Project Templates

Since I love Universal Windows Platform thing (UWP for short), I would like to see my apps running in any Windows 10 enabled devices (Desktop, Laptops, Phablets, Tablets, Phones, Xbox, Surface Hub, IoT Devices, and perhaps Microsoft HoloLens). So, all I need is to create one code base using UAP project templates and done, just deploy to all of the devices I have. Great, so I create a new project, using MonoGame Windows 10 UAP Project. Perfect, right! No, I was wrong. Starting from creating the project until compiling, not even running, it makes my smile suddenly ruin with the error after error I encountered. You can try it for yourself to see all the errors. Apparently, the project template is for Windows 10 Build 10069 SDK which is the technical preview version. My SDK is the latest one which is for Windows 10 Build 10240.

From this experience, I was thinking to create the new MonoGame UAP project template for Windows 10 Build 10240 and above. I know, the MonoGame community will update the template soon, but hey, I’m a developer and I love MonoGame, so let’s go!

First, you still need to download the MonoGame 3.4, I will explain on why you need this later. Here is the link:

Download Link: MonoGame 3.4

MonoGame 3.4 for Visual Studio

Second, you can download the VSIX I made from this link:

Download Link: MonoGameUWPVSIX.vsix

Remember to close all Visual Studio first. Install the VSIX by double-clicking the file and that’s it.

Now, open the Visual Studio 2015 again and create New Project. Go to the Visual C# –> Windows –> Universal template, looks like this;

Creating New MonoGame UAP Project
Creating New MonoGame UAP Project

Just click OK for your first test project.

BEFORE YOU RUN

Yes, before you want to run the app, make sure you set the target platform, choosing the x86 solution platform would be a good idea for the first time run.

x86 Solution Platform For Testing

Than press F6 or Build the Solution for the first time. It will restore the packages from NuGet for a while and… another Error isn’t it. In my case, I see this error;

First Build Error

If you refresh the project in the solution explorer and expand the References, you can see all the packages has been restored and from the error message looks like there is some missing file. Well, just go to the folder. Apparently, the missing file is not missing, only misplace in the folder. All you have to do just move the file.

Moving MonoGame.Framework.xr.xml File

Yes, move the MonoGame.Framework.xr.xml file to MonoGame.Framework folder and that should work.

Press F6 again to build the solution (sometimes I usually always choose Rebuild, don’t know why). And there you go, here is the result;

Great! So, previously “you need” to install the MonoGame 3.4 first. Well, this is for the MonoGame Content Builder (MGCB) that uses MGCB.exe and other builder tools, you can download this and configure by yourself, but it’s better to just install the MonoGame 3.4.

WHAT DID I DO

What I did is actually update the default MonoGame Windows 10 UAP Project template, which is adding some of these lines inside the csproj file. In the configuration property group, I add this line;

And add the import;

That’s all for the .csproj file. This MGCB update is to make the compiler build the content which is in the Content.mgcb file.

MonoGame Content Builder file

One thing that always to remember is the Content.mgcb file Build Action must be set as MonoGameContentReference. Otherwise, the compiler will not execute the MGCB.exe to build the content.

MGCB_ContentBuildAction

Well, that’s it for this MonoGame UAP for Windows 10 Build 10240 with the latest SDK.

NO, WAIT…!

I also tested the app running in Windows Phone 10 on Lumia 630. Looks good.

Game Running in Lumia 630

 

Enjoy! Happy coding…

Leave a Reply

Your email address will not be published. Required fields are marked *