Tricks for importing content files into Monogame

Monogame is an open source replacement for the XNA game development library. It’s pretty neat, you can do a lot of cross platform stuff that XNA could never do. One of the biggest hassles though is that if you an existing XNA project and want to port it to Monogame, the content files need to be setup in a specific way and there’s really not an easy to do them all at once.

I’m gonna walk you through a couple simple copypasta find/replace tricks I’ve been using. Keep in mind, developing with Mono is always a moving target, so anything I post here is proooobably out of date by the time you read it 😉

First, I’m assuming you’ve already got Monogame and Monodevelop installed. Honestly I’ve tried using monogame in Visual Studio, and it’s such a hassle I gave up and went mono all the way down. Monodevelop honestly works better in my experience. So open Monodevelop, create a new project for whatever platform you are developing. Right click in the project and go to Add->Add Files From Folder. Navigate to the location of your existing XNA project and import all the files as links. You should end up with something that looks like this:


The problem is that all my files under the “Content” folder need to have some properties changed. I need to change the Build Action from “None” to “Content”, and need to change the “Copy To Output Directory” from “Do not copy” to “Copy If Newer”. I could open the properties window for each content file and change it by hand, but there are a lot of them and I’m helluva lazy.

Right click the project and select “Open containing folder”. Open the .csproj file in whatever text editor you use. Find the ItemGroup element that contains your content files and highlight the whole thing:


Do a ctrl+shift+h or whatever to do a find/replace “<None ” with “<Content “. Notice the space at the end, that’s important so you don’t screw up the XML tags. Next do another find/replace for “</None>” and replace with “</Content>“. Now all your content files will be properly recognized as content:


To get them to copy to the output directory correctly, do another find replace for “</Content>” and replace with “<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory></Content>“:


Now when you go back to Monodevelop and view the properties for each content file, they should be correct:




Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s