Is there a way to programatically add items to an mgcb file? I’m doing a lot of testing with models and the process of copying/adding/building/copying/running is driving me a bit nuts. I could automate a lot of the laborious process if I could add items and rebuild the mgcb automatically.
If you add the mgcb file to your project and set the build action to MonoGameContentReference and make sure the output directory is the same as your project output dir, it will automatically build if needed when you build your project. This way you only need to add items to the mgcb.
Where should be mgcb file be? I’ve been putting them in the Content folder, but I don’t have the value MonoGameContentReference in the Build property, and I don’t have an Output Directory. ?
MonoGameContentReference should be added when installing MonoGame so if it’s not there, maybe something went wrong with the installation? If you started with a template it should all be fine by default and just adding assets to the mgcb should output the xnb’s in the right folder when you build the project. You can see your output dir in your project properties under build, it’s where ContentManagers look for the xnb’s (bin/… by default).
If you load the mgcb file into a text editor, you will see it is simply a list of command-line parameters. You could easily automate adding items to this file.
The MonoGameContentReference build property is available if you import the MonoGame .props and .targets files in your project file. Have a look at the template project to see where they go in a project file (
MonoGame.Common.props at the top and
MonoGame.Content.Builder.targets at the bottom).