# How can I develop in MonoGame without relying on .xnb files?

I'm new to game development, and MonoGame seems like a beginner-friendly framework, so thought I'd start with that. However, as I started reading tutorials on it, I noticed a common theme: That at its current state, MonoGame needs XNA's content compiler since it doesn't have one of its own. The only problem I have with this is because I'm unable to install XNA (followed instructions on the web, even installed the Game Marketplace). I'm on Windows 8.1, by the way.

Long story short, I gave up on trying to install XNA. However, I have played around a bit with MonoGame and found that you can use raw images (.png in my case) instead of those converted to .xnb. I haven't tried sound, so I don't know if it'll work. Or any other assets for the matter.

My question is, is it possible to develop in MonoGame without using .xnb files? Or, is it possible to develop without XNA's content compiler? If yes, then how?

• "How much harder" is a subjective topic, so I edited that bit out of your question. – user1430 Jan 2 '14 at 15:07
• @Josh - I completely disagree. Degrees of complexity can be objectified. "How much harder" can be conceptually mapped to "degrees of complexity" just fine. – OCDev Oct 17 '19 at 10:25

Yes, you can develop with MonoGame without relying on XNB files. I've been doing it for over a year now and for the most part it's fairly straightforward.

The main thing you are likely to have trouble with is SpriteFont's. What I do is pre-render my fonts onto a texture and render them like normal sprites. I've got a little tutorial over here: http://www.craftworkgames.com/blog/tutorial-bmfont-rendering-with-monogame/

I've never had any trouble with .png files and .wav files work okay too but you have to make sure they are in the correct format. I haven't tried using shader's or anything else really, but I have created a couple of complete games.

You can use XNB Builder. The program still requires XNA .dlls, but you can just download them and put in a folder with the program.

• Distributing the XNA DLLs directly is not, as far as I'm aware, permitted by the EULA. I would not recommend that approach. – user1430 Jan 2 '14 at 19:47
• Is it legal if you have legally obtained the XNA DLLs (like from the installer) ? – Gustavo Maciel Jan 3 '14 at 4:07
• If you have them on your system from an installed version of XNA, that's fine. Nobody (but MS) may distribute the DLLs directly though, so obtaining them in any fashion that doesn't come from the XNA installer is, unfortunately, against the EULA. – user1430 Jan 3 '14 at 22:43
• Ekzo did not recommend downloading XNA DLLs from somewhere unofficial. – Danyal Aytekin May 9 '14 at 18:54
• You also need to install XNA Framework Redistributable 4.0 to be able to run this. – Minh Nguyen Oct 12 '15 at 11:43

It's worth nothing now that Monogame now has it's own Content Pipeline Builder Tool that removes any dependencies on the old XNA framework DLLs.

It includes a command line (linked above) as well as a GUI Tool that can be used to generate your XNB files from textures etc and then copied into your game project.

If you are working in Visual Studio then the .mgcb file has it's own Build Action (MonogameContentReference) and your XNB files will be generated as a part of your Visual Studio build process, thus making a pretty seamless workflow, or at least a similar one to what XNA provided with its Visual Studio project templates.

Personally, I typically keep my assets in a separate folder beside my Game Project folder and put the .mgcb file there. I then include the .mgcb file in the game project as a linked item reference.

Old topic but I found it so maybe someone else will too :)

As mentioned by craftworkgames, you can develop without XNB ( well, at least with textures and some audio formats ) .

You can load a png file using a Stream object ( must be a seekable stream, so you may need to copy from a StreamReader into a Memory Stream , then pass the memory stream itself to the texture2d constructor ).

The same should be possible with Wav files.

However, if you want to load FBX models or .X models, I am not sure if the Model / Mesh objects can be initialized directly from a seekable file stream.

Note:

• I have also initialized textures by loading them from a HTTP streams ( read from http stream - copy into seekable memory stream - pass stream to texture2d constructor ) - which allowed my game to download textures from a website via HTTP protocal instead of disk.

Shaders can be generated at runtime - initialized from byte array, and I think also from a string containing code. It "should" be possible to generate shaders in real time or even load them from remote sources, or from disk without requiring XNB files.

I am not sure if the DirectX version of the MonoGame supports this yet ( in the repo ) , but I think it shouldn't be hard using the current OPENGL based builds.

If you want to avoid having to use XNB, it might be a good idea to create your own content manager to replace the XNA/Monogame versions from scratch - thus undermining the entire content pipeline - but could also imply supporting your own formats that wont require XNA specific features.

I would say you're approaching the issue in the wrong way.

Firstly try and tackle the XNA issue, because it is likely that as the MonoGame project is all about doing XNA as an open source implementation that it will use similar or the same file types in the same manner. Although MonoGame is not dependant on XNA installing correctly (see edit - Thanks Josh) here are some things to check for XNA issues:

• Does your machine meet the minimum specs for development?
• Have you installed all the prerequisites? What sort of errors are you getting?
• Sometimes previous versions of .net framework and XNA studio can interfere, make sure you un-install these before installing XNA to ensure you are starting from scratch on the installation.
• Could you work completely in the XNA studio without worrying about MonoGame and then easily port it to MonoGame later on? As this was the original intention to MonoGame, to allow existing developers to port over to it easily, this would be a viable path to take.

If your machine is unable to work with XNA currently there may be related issues down the line with MonoGame. It is always worth ironing out development environment installation issues first before starting on a project.

Edit: As Josh mentioned in the comments - XNA has been abandoned. I had not actually realised myself, so although the example from XNA installer affecting MonoGame is not an issue in this case I still believe it is worth noting that install issues are something to clear up before project development commences.

• I believe my machine does meet the minimum spec. It's a 2nd gen i5 2.5 GHz with 4gb of memory and Windows 8.1 on it. About the prerequisites, yes, I've installed them. In the following order: VCS 2010 Express, Games for Windows Marketplace, and then XNA. XNA failed to detect my copy of VCS2010 and refused to install. – Truerror Jan 2 '14 at 14:51
• XNA's been abandoned, and while it technically does work on many modern machines, the installer has turned out to be very brittle and not very future-proof, so it's not necessarily true that a problem installing XNA will translate to a problem that will impact MonoGame. That said, this answer isn't really addressing the question that was asked, which is still a valid query regardless of whether or not there is a problem with somebody's XNA install. – user1430 Jan 2 '14 at 15:05
• Well, MonoGame itself installs without a hitch on my system, it's XNA that I have trouble installing. Tools like XNABuilder and XNA Content Compiler are nice, but they need XNA installed. So for now, I'm following craftworkgames suggestion and use raw assets instead. News is, the MonoGame content compiler is underway, and will most probably be in the next major version. – Truerror Jan 3 '14 at 12:22
• Nice, good to know, I'm sorry I didn't answer your question directly but I have had so many issues get solved by taking the time to reinstall things properly and solve those issues first - thought it was important to mention. – Tom 'Blue' Piddock Jan 3 '14 at 12:25