Welcome to MSDN Blogs Sign in | Join | Help

Why does my content rebuild every time?

The XNA Framework Content Pipeline tries to use incremental rebuilds wherever possible. This means if you add a hundred content files, build your project, change just one of those files, then build again, only that specific file needs to be rebuilt.

In a perfect world this would work 100% of the time, but in reality we sometimes rebuild more content than is strictly necessary. Most often this happens if you make a change to a custom processor assembly. The pipeline does not keep track of which assemblies were involved in building which pieces of content, so if any custom assembly changes, all content will be rebuilt. Unwanted rebuilds may also occur when changing project settings, if you have circular project references, or if the Content Pipeline cache file is somehow getting deleted.

If you think your content is rebuilding more often than it should, you can find out why by turning up the MSBuild output verbosity. If you rebuild-all with the Skinned Model sample, the Visual Studio output pane will normally show something like:

    Building dude.fbx -> SkinningSample\bin\x86\Debug\Content\dude.xnb 
    Building head.tga -> SkinningSample\bin\x86\Debug\Content\head_0.xnb 
    Building SkinnedModel.fx -> SkinningSample\bin\x86\Debug\Content\SkinnedModel_0.xnb 
    Building jacket.tga -> SkinningSample\bin\x86\Debug\Content\jacket_0.xnb 
    Building pants.tga -> SkinningSample\bin\x86\Debug\Content\pants_0.xnb 
    Building upBodyC.tga -> SkinningSample\bin\x86\Debug\Content\upBodyC_0.xnb 

Open the Tools / Options menu in Visual Studio. If you are using C# Express, make sure the Show all settings box is checked. Expand Projects and Solutions, select the Build and Run node, and change the MSBuild project build output verbosity setting from Minimal to Normal.

Now when we rebuild-all, the output pane shows:

    Target CoreCompile: 
        Building dude.fbx -> SkinningSample\bin\x86\Debug\Content\dude.xnb 
        Rebuilding because asset is new 
        Importing dude.fbx with Microsoft.Xna.Framework.Content.Pipeline.FbxImporter 
        Serializing obj\x86\Debug\dude_0.xml 
        Processing dude.fbx with SkinnedModelPipeline.SkinnedModelProcessor 
        Compiling SkinningSample\bin\x86\Debug\Content\dude.xnb 
        (etc)

If we make a change to SkinningData.cs, which changes the custom pipeline assembly, the next build will show:

    Target CoreCompile: 
        Rebuilding all content because pipeline assembly SkinnedModelPipeline.dll has changed 
        Building dude.fbx -> SkinningSample\bin\x86\Debug\Content\dude.xnb 
        Importing dude.fbx with Microsoft.Xna.Framework.Content.Pipeline.FbxImporter 
        Serializing obj\x86\Debug\dude_0.xml 
        Processing dude.fbx with SkinnedModelPipeline.SkinnedModelProcessor 
        Compiling SkinningSample\bin\x86\Debug\Content\dude.xnb 
        (etc)

If you find that content keeps rebuilding because assemblies are changing, consider splitting these assembles to separate game logic (which tends to change often) from content data types (which change less often). If your content project can avoid referencing your game logic assembly, it will no longer need to rebuild each time that code changes.

Published Friday, August 14, 2009 10:03 AM by ShawnHargreaves

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

Tuesday, August 18, 2009 10:00 PM by Juan Campa

# re: Why does my content rebuild every time?

On our project, we hit that exact problem, and at a certain point it became very painful because a full content build took more than ten minutes to complete. We solve it by splitting the content into two separate Content Projects, one that referenced the ever-changing-content-processor project, and the other which only had content that didn't need special processing (plain models, textures, spritefonts, etc)

Saturday, November 28, 2009 1:59 AM by Darren Grant

# re: Why does my content rebuild every time?

Same scenario, except our content takes almost two hours to fully build because there is so much. ;)

Exactly the same solution too: I separated the single content project into sub-projects.  As an added step I culled pipeline assembly references to just those needed by each sub-project.

Leave a Comment

(required) 
required 
(required) 

  
Enter Code Here: Required
 
Page view tracker