Using the MonoGame Content Pipeline - galacticglum/MonoGameDesktopTemplate-YRDSB GitHub Wiki

MonoGame comes bundled with a tool which builds and packages your game's content into a compact binary format. This process is called building your content, and the tool that performs this bundling is called the MonoGame Content Build (MGCB for short) pipeline.

Ensure that you have downloaded the file "MGCB_ContentPipeline.zip" and you have extracted its contents onto a USB drive (or other directory that allows you to run executable files. Preferable the same drive where you will be storing your MonoGame projects).

Once extracted, you should have a folder on your drive with name "MGCB_ContentPipeline". Do NOT alter anything inside this folder as it may corrupt the pipeline tool installation. Inside this folder, there should be another folder and a shortcut (called "MonoGame Pipeline Tool"). You will use the shortcut to access the MGCB pipeline tool.

Adding Content

Once you have created your project, there will be a folder called "Content" which contains a file called "Content.mgcb". This file is used by the MGCB pipeline tool (The ".mgcb" file is similar to a Visual Studio solution file. It defines the project in terms of its content. It is VERY important this file is NOT removed and/or manually modified).

The following steps outline how to add content to a MonoGame project (in this example, we will add an image).

  1. Place your content file inside the "Content" folder of your project.
  1. Open the MGCB file using the shortcut contained in the "MGCB_ContentPipeline" folder which you extracted earlier.
  2. Load your content project by selecting File → Open and then navigating to your "Content.mgcb" file.

figure-2: MGCB pipeline tool dropdown Content.mgcb file in its directory

  1. Once the "Content.mgcb" file has opened in the MGCB pipeline tool, right-click the project "Content" and click Add → Existing Item.
  1. Navigate to the content file that you want to add.
  1. Once you have selected the file you want to add, click "Open".
  2. The file will now appear under the project in the MGCB pipeline tool.

Repeat this process for all content files that you want to use.

Building Content

In MonoGame, before you can access content in your project, you need to first build it (i.e. like building/compiling a program before running it). MonoGaame does this because it needs to process the content and convert it into a compact binary format. Fortunately, building content is super simple with the provided template.

In the MGCB pipeline tool (load the "Content.mgcb" for your project file if it is not already loaded), click the "Build" icon.

You can also "Rebuild" your project which will process ALL content files, while building only processes NEW content files. Rebuilding can be useful when you want to make sure that all content files are updated.

After you click "Build", you will see new information appear in the "Build Output" window on the right-hand side of the window. Wait until you see the "Build succeeded" message.

NOTE: You must build the content whenever you add or update content files.