Retrocade.net - Indie game dev Retrocade.net - Indie game dev

Indie Game Dev

Updating MonoGame from 3.5 (NuGet) to 3.6 (source)

For various reasons I had to update from MonoGame 3.5 (installed using NuGet) to 3.6 (using source code). Here is the process and issues I encountered:

  1. Most important – I used Rider 1.0 EAP (Build #RS-163.10479) for this, on Windows 8.1.
  2. Start with checking out the source code from GitHub.
  3. If, like me, you default to using SSH and get errors saying you don’t have the permission to clone the repo just switch to HTTPS.
  4. Follow the rest of the instructions from the page. Below are the steps I did specifically:
    1. Run git submodule update --init to initalize submodules.
    2. Run Protobuild.exe, it took roughly half a minute to finish and generated lots of output.
  5. Open up your project in Rider or your IDE of choice – the steps might be slightly different for you if you’re not using Rider.
  6. Open up NuGet panel and remove MonoGame from it.
  7. Right click on your solution, select “Add existing project” and navigate to MonoGame/MonoGame.Framework/ and select one of the projects to include.
  8. Right click on each project, select “Add reference” and chose MonoGame from the list.

That’s it for the project setup. Now we need to iron out any leftover compilation errors and other issues:

  1. I had some references to OpenTK namespace but they weren’t used so it was as simple as removing them.
  2. I have used OpenTK‘s Vector2 class in one place, just had to hit Alt+Enter for it to auto import the correct one.
  3. Content loader failed on IngameSheetTexture = content.Load("sheets/ingame.png"); – whoops. Turns out this code now only allows .xnb files? Let’s investigate… Found the culprit. You need to directly use the FromStream methods. Clunkier but I can see why they made it so, the new, working code looks like this:
    using (var assetStream = TitleContainer.OpenStream("Content/sheets/ingame.png")) {
        IngameSheetTexture = Texture2D.FromStream(graphicsDevice, assetStream);
    }

And now it works!

UpdatingMonogameStep7