Embedding MonoGame’s Content Pipeline vs. a Separate Content Project
Choose between embedding MonoGame’s Content Pipeline in your game project or keeping it separate, with concrete steps, trade‑offs, and verification tips.
09 Sept 2026, 16:50 UTC

The decision point
When you start a MonoGame project you must decide how assets will be built. The Content Pipeline (MGCB) can be run as a standalone project that produces .xnb files, or it can be pulled into the main game project via the MonoGame.Content.Builder NuGet package so that content is built automatically during the usual compile step. This choice affects iteration speed, team workflows, and continuous integration.
Why the choice matters
Asset builds are not free; each texture, model, or font triggers an importer/processor chain that can take seconds on large projects. If the pipeline runs outside the game project, developers must remember to launch mgcb-editor or the CLI before testing, which adds friction and a chance of running stale assets. Conversely, bundling the pipeline with the game means every dotnet build (or IDE rebuild) also rebuilds content, guaranteeing that the runtime sees the latest version but potentially lengthening the inner‑loop build time.
Embedding the pipeline with MonoGame.Content.Builder
Add the NuGet package to your game project:
dotnet add package MonoGame.Content.Builder --version 3.8.1
Then create an Content.mgcb file at the root of the project (or inside a Content folder) and reference it in the project file:
<ItemGroup>
<None Update="Content.mgcb">
<Generator>MonoGameContentBuilder</Generator>
<LastGenOutput>Content.mgcb</LastGenOutput>
</None>
</ItemGroup>
When you build, the package’s MSBuild target invokes mgcb with the Platform property set to the current target (e.g., DesktopGL on Windows, Android on a CI agent). The generated .xnb files appear alongside the compiled assemblies in bin\Debug\net6.0\Content (or the appropriate folder for your framework).
Keeping a separate content project
Alternatively, create a second project of type MonoGame Content Project (template available via the MonoGame Visual Studio extension). This project contains only the Content.mgcb file and any source assets. The game project references the content project as a dependency:
<ItemGroup>
<ProjectReference Include="..\MyGame.Content\MyGame.Content.csproj" />
</ItemGroup>
In this setup, the content project builds independently, producing .xnb files in its own output folder. The game project then copies those files to its content root via a post‑build step or by setting CopyToOutputDirectory on the referenced assets. This separation makes it easier for artists or designers to open the content project in mgcb-editor without loading the entire game solution, and it allows CI pipelines to cache the content build step.
Worked example: switching modes
Suppose you have a DesktopGL game with a sprite sheet hero.png. First, embed the pipeline:
- Add the NuGet package as shown above.
- Create
Content.mgcband setPlatformtoDesktopGL. - Add
hero.pngto the mgcb file, leave the processor asTextureProcessor. - Run
dotnet build. Verify thatbin\Debug\net6.0\Content\hero.xnbexists.
To move to a separate content project:
- Remove the NuGet package.
- Create a new
MonoGame Content ProjectnamedMyGame.Content. - Move
Content.mgcbandhero.pnginto that project. - Add a project reference from the game to the content project.
- In the game project, set
CopyToOutputDirectorytoPreserveNewestfor the content folder. - Run
dotnet buildagain and check that the .xnb appears in the game’s output folder.
Both approaches produce identical .xnb output; the difference lies in where the build target lives and how easily the workflow can be split.
Trade‑off and limitation
Embedding the pipeline simplifies onboarding for new developers because a single dotnet build yields a runnable game. However, it couples content rebuild frequency to code changes: even a minor script tweak triggers a full content rebuild, which can slow inner‑loop iteration on large asset sets. A separate content project decouples the two, allowing you to rebuild only when assets actually change, but it requires an extra step to ensure the content project is built before the game runs (e.g., a CI stage or a pre‑launch script).
Practical verification
To confirm that your chosen setup works, run the game and attempt to load an asset:
Texture2D tex = Content.Load("hero");
If the texture appears on screen without a ContentLoadException, the pipeline has produced a valid .xnb for the current platform. For CI, add a step that runs dotnet build (or msbuild for the content project) and asserts that the expected .xnb files exist in the output directory.
Actionable closing
If your team values a single‑command build and is comfortable with occasional extra rebuild time, embed the Content Pipeline via MonoGame.Content.Builder. If you have dedicated asset creators, want faster iteration on code changes, or need to cache content builds in CI, keep a separate content project and reference it from the game. Either way, verify the output by loading a known asset after each build to catch mismatched platform settings early.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.