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 ).
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
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;
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.
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;
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.
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;
<MonoGameContentBuilderExe> $(MSBuildExtensionsPath)\MonoGame\v3.0\Tools\MGCB.exe </MonoGameContentBuilderExe>
And add the import;
<Import Project= "$(MSBuildExtensionsPath)\MonoGame\v3.0\MonoGame.Content.Builder.targets" />
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.
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.
Well, that’s it for this MonoGame UAP for Windows 10 Build 10240 with the latest SDK.
I also tested the app running in Windows Phone 10 on Lumia 630. Looks good.
Enjoy! Happy coding…