.TXT files don't work in the content manager?

Hi again, all.

I’m having another spot of bother, but this time it’s with setting up tilemaps - using SimonDarksideJay’s 2D platformer code samples (found here) was going well and without any errors until it came time to start implementing tilemaps.

It’s possible I missed something that makes adding .TXT files possible since I’m still very new to Monogame and making this 2D platformer for a university assignment, but I’ve added a folder to the content manager called Levels, and inside are three .TXT files titled {0}, {1} and {2} respectively. None of this is changed from the sample code so, that should be fine.

The issue comes when I then try to run the code - I get these error messages:

Error MSB3073 The command “dotnet C:\Users\Squid.nuget\packages\monogame.content.builder.task\3.8.0.1641\build\…\tools\netcoreapp3.1\any\mgcb.dll /quiet /@:“G:\Work Related Learning\WRLPlatformer\Content\Content.mgcb” /platform:Windows /outputDir:“G:/Work Related Learning/WRLPlatformer/Content/bin/Windows/Content” /intermediateDir:“G:/Work Related Learning/WRLPlatformer/Content/obj/Windows/Content” /workingDir:“G:/Work Related Learning/WRLPlatformer/Content/”” exited with code 4.

Couldn’t find a default importer for ‘G:/Work Related Learning/WRLPlatformer/Content/Levels/{2}.txt’!
Couldn’t find a default importer for ‘G:/Work Related Learning/WRLPlatformer/Content/Levels/{1}.txt’!
Couldn’t find a default importer for ‘G:/Work Related Learning/WRLPlatformer/Content/Levels/{0}.txt’!

Is there any way I can get the engine to recognise .TXT files the way it apparently does in the sample code, or do I need to use a different file type?

Any help would be massively appreciated (and sorry if I seem hopeless, most posts covering this issue on the internet lead to 404’d webpages! :sweat_smile:)

Additional information:
I’m using the most recent release, NuGet 3.8 on Visual Studio 2019.
The project I set up is “for the Windows desktop using DirectX” and I’m on Windows 10 x64.
I’m testing all this on my laptop, and it’s a computer-only project so the gamepad/touch features in the sample code have been deleted / are not included in my project.

MonoGame Content Manager is used to take engine-unfriendly assets (like PNGs) and “compile” them (or “import/build/etc”) them into MonoGame assets (*.xnb files and such).

So, what you’re running into here is that you’re trying to feed a file to the Content Manager that it doesn’t have a default way to process. Because it’s just a simple text file, and presumably you don’t want it to do anything to it.

Solution: Just set the build action to “Copy” and when it builds all your content it will just dump that text file in there with the built assets

Example of a text file in your .mgcb file, as opposed to something like a sound effect.

#begin textFile.txt
/copy:textFile.txt

#begin sounds/airBlast.wav
/importer:WavImporter
/processor:SoundEffectProcessor
/processorParam:Quality=Best
/build:sounds/airBlast.wav
2 Likes

This worked perfectly, thank you so much!!

2 Likes