# MonoGame “couldn't find a default importer” for .txt file?

I'm trying a solution in MonoGame to create levels from a .txt file, but the pipeline tool fails when trying to build the Content.mgcb correctly:

❌ Skipping HighResolutionContent\Backgrounds\Layer1_0.png

C:/Users/foo/Documents/Visual Studio 2017/Projects/Platformer/Content/HighResolutionContent/Backgrounds/Layer1_0.png

Couldn't find a default importer for 'C:/Users/foo/Documents/Visual Studio 2017/Projects/Platformer/Content/HighResolutionContent/Levels/2.txt'!

Couldn't find a default importer for 'C:/Users/foo/Documents/Visual Studio 2017/Projects/Platformer/Content/HighResolutionContent/Levels/0.txt'!

Couldn't find a default importer for 'C:/Users/foo/Documents/Visual Studio 2017/Projects/Platformer/Content/HighResolutionContent/Levels/1.txt'!

Visual Studio shows me this:

❌ The command ""C:\Program Files (x86)\MSBuild\MonoGame\v3.0\Tools\MGCB.exe" /@:"C:\Users\foo\documents\visual studio 2017\Projects\Platformer\Platformer\Content\Content.mgcb" /platform:Windows /outputdir:"C:\Users\foo\documents\visual studio 2017\Projects\Platformer\Platformer\Content\bin\Windows" /intermediateDir:"C:\Users\foo\documents\visual studio 2017\Projects\Platformer\Platformer\Content\obj\Windows" /quiet" exited with code 3.

❌ Couldn't find a default importer for 'C:/Users/foo/Documents/Visual Studio 2017/Projects/Platformer/Content/HighResolutionContent/Levels/0.txt'!

❌ Couldn't find a default importer for 'C:/Users/foo/Documents/Visual Studio 2017/Projects/Platformer/Content/HighResolutionContent/Levels/1.txt'!

❌ Couldn't find a default importer for 'C:/Users/foo/Documents/Visual Studio 2017/Projects/Platformer/Content/HighResolutionContent/Levels/2.txt'!

• What do the file properties look like on the text file inside Visual Studio? – doppelgreener Jun 12 '17 at 14:25
• If you mean the properties box, it is empty. – Salinator Jun 12 '17 at 14:39
• Yep, that's what I mean. Gotcha, OK. – doppelgreener Jun 12 '17 at 14:56

You're getting this message because the pipeline doesn't contain a content importer for a .txt file. Plain-text files generally don't require any special processing, and don't need to be converted to a binary format (which is what the content pipeline is for).

There's an option in the MonoGame Pipeline Tool to set the Build Action to "Copy" instead of "Build", which is probably what you're looking for. The file will then be copied as it is. It won't be converted into a .xnb file, and you'll have to read the file manually (not using ContentManager).

The content pipeline converts source files into binary .xnb files. It has predefined content importers for most standard audio and image formats that will import the file, process it into an object, and then write the object into a binary .xnb file.

At runtime, when you use a ContentManager to load your content, the binary .xnb file gets read and converted into your output type (such as Texture2D or SoundEffect).

All that's known about a .txt file from it's extension is that it contains text, and all of this importing/processing/writing/reading is unnecessary when something like File.ReadAllText exists.

If your .txt file is supposed to represent something that can be converted into an object, such as a game level, you could consider writing your own content importer if you want your .txt file to be converted to an .xnb. The downside of this is that your level files would need to be rebuilt whenever they're modified, but you gain some protection against players that may try to modify DifficultLevel.txt to make it easier.

MSDN has a good tutorial on writing your own custom importer, and it's all still relevant in MonoGame, aside from actually getting the MonoGame Content Builder to use your custom importer. I found a reply to a question on MonoGame's forum that helped me figure it out.