Content Pipeline can't build .tmx files

I’ve been trying to find a way to load .tmx level files into Monogame and my latest attempt is using Extended. I install the package via NuGet then reference the MonoGame.Extended.Content.Pipeline.dll in the Pipeline and add a .tmx file I quickly made. When I try to build this I get this error:

‘The command ““C:\Program Files (x86)\MSBuild\MonoGame\v3.0\Tools\MGCB.exe” /@:“C:\Users\Gebruiker\Documents\Visual Studio 2015\Projects\Game1\Game1\Content\Content.mgcb” /platform:Windows /outputDir:“C:\Users\Gebruiker\Documents\Visual Studio 2015\Projects\Game1\Game1\Content\bin\Windows” /intermediateDir:“C:\Users\Gebruiker\Documents\Visual Studio 2015\Projects\Game1\Game1\Content\obj\Windows” /quiet” exited with code -1073741819.’

Building the file in the Pipeline causes it to freeze at ‘untitled.tmx’. Running the Pipeline in debug mode leads to a Null Reference Exception in MonoGame.Extended.Content.Pipeline.dll. Even when I try to build the Pipeline in Debug Mode without the .tmx file I get ‘An unhandled Microsoft .NET Framework exception occurred in MGCB.exe [78556].’, but it does build succesfully.

How can I solve this issue so that I can build a content file with .tmx files?

EDIT: For some reason, my game doesn’t start with Extended either now. I can press Start and it’ll build the project succesfully, but won’t open a window for the .exe. No process either. Uninstalling Extended fixes it.

EDIT2: After reinstalling Extended it seems to work again. It only generates an issue when I try to Add a .tmx file to the Pipeline, bringing me back to the topic issue.

Hi @Yinhao

First of all, thanks for trying MonoGame.Extended. We’ve been working very hard.

I’m sorry to hear that you’re having some trouble with it. I’d really like to get issues like this sorted out as soon as possible so I’m going to try and help you in every way I can.

Unfortunately, the error message doesn’t leave us with much to go on but there’s plenty of things we can do to get to the bottom of it.

  1. What version of MonoGame.Extended do you have installed? The latest release on NuGet is 0.4.64
  2. What version of MonoGame do you have installed? The latest official release is 3.4 but many people are running a more recent 3.5 development build. There’s a lot of changes between these versions of MonoGame.
  3. Can you build the MonoGame.Extended samples? One of the samples contains a Tiled map that should work.
  4. If you can build the samples, please try loading the sample map in your own project. I think you’ll need level01.tmx, free-tileset.png and hills.png.
  5. Would you mind giving me a copy of your .tmx and associated tileset files? If I can reproduce the issue at my end it’ll make it a lot easier to fix.

Again, I’m sorry this has happened. I’m sure we can fix it.

Hi @craftworkgames

Thanks a lot for your assistance in resolving this issue. I’ve tried all the steps you’ve described and have gotten the following results:

  1. The version of MonoGame.Extended that I’m using is the latest version from NuGet, 0.4 -4.
  2. The version of MonoGame that I have installed is the latest official release, 3.4. Would upgrading to the 3.5 development build be advised?
  3. Trying to build the sample project in MonoGame.Extended, Sandbox leads to a lot of errors. The Sandbox project has the same error as my own project, but instead of ‘exited with code -1073741819’ the description writes ‘exited with code 12’. A quick scroll through the errors (there are 132 errors when building the solution) and it seems to stem mainly from the fact that ‘The type or namespace name ‘Pipeline’ does not exist in the namespace ‘Microsoft.Xna.Framework.Content’’. This namespace doesn’t seem to be present in the Samples or in my own project either. Trying to build the Content.mgcb through the pipeline leads to failures, with error messages such as:
  • error: Failed to create importer ‘TiledMapImporter’/‘TexturePacketJsonImporter’/‘AstridAnimationImporter’
    I assume these errors come from the fact that these classes don’t seem to build properly due to the Pipeline namespace being missing.
  1. As for Samples.Extended, trying to build the Content.mgcb through the Pipeline works fine. The project builds fine and I can see the map correctly too.
  2. Loading the sample map + the .png files into my own project works fine, and the project builds correctly in the Pipeline.
  3. Here is a download link for my .tmx and the tile I used. It’s a map I quickly through together for a sidescroller game and uses only a single tile.

Considering how the Samples project builds correctly, also on my own project, I’m led to believe the issue might be with me using Tiled incorrectly. I hadn’t used it prior to yesterday and may have done something wrong when creating the map.

I hope any of these results can lead to a solution and again, thanks your for help. :slight_smile:

I had the same issue right now. To make it work I just placed the tileset image at the same folder of the .tmx file. I would like to place the tileset image into a different folder.

@Yinhao

The Problem

The good news is that I managed to reproduce the issue and I understand the problem now :smile:

It turns out that MonoGame.Extended doesn’t currently support “Collection of Images” for tilesets.

The workaround for the moment is to change your tilesets to be “Based on Tilset Image”. Something like this:

Unfortunately, you’ll also need to delete the broken tilsets and this will mean you’ll have to recreate the map.

So what’s happening under the hood?

When you save a “Collection of Images” tilset the XML looks like this:

<tileset firstgid="2" name="basictile" tilewidth="32" tileheight="32" tilecount="1" columns="0">
  <tile id="0">
   <image width="32" height="32" source="basictile.png"/>
  </tile>
</tileset>

When you save a “Based on Tileset Image” tileset the XML looks like this:

 <tileset firstgid="1" name="basictile" tilewidth="32" tileheight="32" tilecount="1" columns="1">
  <image source="basictile.png" width="32" height="32"/>
 </tileset>

The differences are fairly subtle at first glance but the actual cause of the issue is the way the importer is handling the “source” property.

if (!string.IsNullOrWhiteSpace(tileset.Source))
{
    // import tileset
}

The importer is expecting the “source” property to always have a value but in the case of the “Collection of Images” it will be null.

Other issues

That explains the issue and points us in the right direction to fix the bug but there’s a few other things that bother me about this:

  1. The importers don’t really do any logging. It’s pretty difficult to debug these things as it is.
  2. If something is not supported by the importer it should throw an error.
  3. It’s still unclear to me why the MonoGame Pipeline tool is hanging.

I’ve raised this issue on our github issues page so we can get around to fixing it properly in the next version.

@RafaelAlmeida I’m not exactly sure how this works in the Tiled map editor. I know some of the other importers handle this correctly. I’ve raised another issue about it.

@Yinhao How did you go with this? Everything working now?

@craftworkgames Glad you were able to reproduce and identify the issue so quickly! I quickly remade the map using a ‘Based on Tileset Image’ tileset and it works perfectly. Your explanation as to what happens under the hood was also quite helpful in understanding the issue.

Finally, it was indeed very frustrating to just have the Pipeline tool hang on me, because it gave me the impression I just had to wait for it to be done building. Unfortunately it still wasn’t done 2-3 hours later.

Regardless, thanks for your assistance and glad I could help identify an issue. :slight_smile:

I’d be surprised if anything ever took more than a couple of minutes for future reference.