MonoGame Content Pipeline Extension Tutorial

Hi everyone,

I’ve made a deep dive tutorial on creating a MonoGame Content Pipeline Extension. It’s not brief, it is a deep dive into the anatomy of it all, but hopefully it will help some who would like to make their own extensions to load custom file types.

You can find the tutorial at Introduction | MonoGame Content Pipeline Extension Tutorial Series | Aristurtle

I also have a video for those that prefer listening to videos in the background instead of reading a text dump


Kinda reminiscent of my old tutorial
Getting Started with MonoGame using XML - YouTube

Great work @Aristurtle :smiley:

1 Like

Wow! It’s amazing! This is what you need. I have looked at this topic very often, but there is very little information (mostly on the xna archive). Now all the information is in one place and very accessible. Thank you!

Thanks. I remember warching your videos years ago when i was first starting out, they helped a ton

Glad it was helpful. It is quite the text dump, but i wanted to be sure to cover as much of it as possible as a deep dive.

Hopefully its not too boring a read.

Love it! Thanks for sharing!

1 Like

First I am learning of your tutorial. Thanks for sharing as well. I’ll be checking them out.

1 Like

Great tut, but I’m having an issue.

So, I have done these before in earlier versions, and never had an issue, but I think I am doing something daft, or missing a step somehere.

My issue is once I have my exension written and added to the MGCB references, it then never shows up in the list of importers or porcessors…

I have gone super basic now too, so just create a Conten Extension project (from the template), leave ALL the classes as they are and add a .txt file to my content files. The default Importer1 and Processor1 are not in the list of options :confused:

I have no idea what I am missing, any ideas?


I know I must be doing something daft…

Is there anyway you can put it on github or somewhere i can see it. There are a million things that can go wrong with pipeline extensions :smile:

Ill knock up a simple project and post it up. Thanks :slight_smile:

1 Like

OK, created a cross platform project. Created a Text folder in content and put a blank text file there.

Create a content pipeline extension poject, changed nothing, and added it as a reference to the first projects MGCB.

Niether Importer1 or Processor1 show up in the list of importers/processors :frowning:

I know I am doing something daft…

Thanks for taking the time to look.

Repo is here

Just going by the example repo, the first issue is that both the Importer1 and Processor1 are returning back default(TOutput) which is going to result in them returning null. Can’t return null.

The second issue is that the Processor1 has a return type TOutput of System.String which is going to cause issues when you create the writer to write the xnb file. It’s always best to wrap your processor result in a custom class DTO model so there is not interference with the built in content pipeline processors that return standard types like string.

Making these changes it works

Ok, i just assumed the initial code woukd at least bind up.

Naturally my actual code didnt return null.

Ill get that working then put my pipeline in, its pretty much what you did in the tut, but not as flexible as yours.

When i do a generic solution ill add ot to my nuget repo :wink:

Thanks for your time mate :slight_smile:

1 Like

Hmm, I’m still being a bit dim…

Importer now looks like this:

using Microsoft.Xna.Framework.Content.Pipeline;
using System.IO;
using TImport = System.String;

namespace MonoGameConentPipelineIssue_Extension
    [ContentImporter(".txt", DisplayName = "Importer1", DefaultProcessor = "Processor1")]
    public class Importer1 : ContentImporter<TImport>
        public override TImport Import(string filename, ContentImporterContext context)
            return File.ReadAllText(filename);

and the processor like this:

using Microsoft.Xna.Framework.Content.Pipeline;
using TInput = System.String;
using TOutput = MonoGameConentPipelineIssue_Extension.Models.ProcessorResult;

namespace MonoGameConentPipelineIssue_Extension
    [ContentProcessor(DisplayName = "Processor1")]
    internal class Processor1 : ContentProcessor<TInput, TOutput>
        public override TOutput Process(TInput input, ContentProcessorContext context)
            return new TOutput()
                Data = input,

And it’s still not showing up in my list :confused:

I have commited these changes now… I would message you, but I think me going throuhg this might help others too :slight_smile:

These are the exact same changes I made.

Can you open the MGCB Editor and click Help > About and confirm the version number?

1 Like

Sure this is what it gives me.

Oh, that is an other version right?

hmm if I run “dotnet mgcb-editor”

I get a different version :confused:

[The forum wont let me post 3 times in a row, so puttin all my findings in here :stuck_out_tongue: ]

OK, somethig is not right on my machine.

If, from within VS I right click the Content.mcgb file and select Open With and choose MGCB Editor, it opens it up with the later version, and the extension works.


If I double click it from file explorer, it opens it with the older verision and the extension does not work lol

Guess I have an old version bound to the file type, ill see if I can sort that out. I knew it must be something daft :slight_smile:

After a quick DM with @Aristurtle I have the olderverion installed as a global tool, removing that now.

Fingers crossed this is my last hurdel :smiley: