#9397·MonoGame

Content Builder: BuildAsset appends hashcode to dependencies already built by wildcards

Author: thomasnalixCreated Jun 28, 2026Updated Oct 1, 2026
Labelsbugscope: content-pipelinescope: content-builderstatus: needs-design

Intent

When using the new in-preview Content Builder, calling context.BuildAsset with explicit processor/importer instances appends a hashcode to the resulting .xnb filename (like beach.spring.88ec1b23.xnb)

This happens even if the asset is already being built globally via a wildcard pattern (like Textures/*.png), resulting in two separate files in the output directory:

  • beach.spring.xnb (from the wildcard build)
  • beach.spring.88ec1b23.xnb (from BuildAsset as a dependency)

Example : At runtime, my game relies on a naming convention to dynamically swap textures (e.g., swapping a base tileset texture with its seasonal variant like winter/spring). Because BuildAsset forces the dependency to look for the hashed filename, it becomes impossible to easily swap or target these assets programmatically at runtime without knowing the generated hash.

Solution :

  1. Post-build redirection suggested by @tomspilman very brielfy At the end of the content build, add a step to check for non-hashed duplicates. The hashed XNB file could then be rewritten to act as an external reference redirecting to the non-hashed XNB.

I add an other proposition : 2. An explicit "Opt-out" parameter in BuildAsset Add an optional flag to the BuildAsset method (like bool appendHash = true). This would allow developers to explicitly bypass the hashing when they know for sure that parameter collisions won't happen.

I find the first option extremely interesting and logical.if the same file is added to the same directory, there's a 100% chance it will be a case of merging.

Motivation

In game development, we can need both build time safety and predictable, deterministic filenames for our runtime systems

Currently, the hashed output makes it impossible to programmatically map assets at runtime based on naming conventions (swapping seasonal textures). It forces a non-deterministic workflow that breaks dynamic loading. Implementing a way to resolve these to their clean, non-hashed counterparts would provide the necessary flexibility and simplicity for developer to manage their assets effectively without sacrificing pipeline reliability.