Search code examples
xnamonogamecontent-pipeline

Linking Content Project (XNA) to a non XNA project


Can I reference a Content Project to a Non-XNA project (MonoGame, if it's important)?


Solution

  • Not directly.

    The ability to add a content project reference to a project is only available for projects of the types "XNA Game" and "XNA Game Library".

    One trick that I use when I want to build and include an XNA Content Project in a WinForms project is to make an empty XNA Game Library project. Reference the XNA Game Library project from the main (Windows) project, and the Content Project from the XNA Game Library project.

    Whether this will work for MonoGame is another matter.

    The alternative is to simply have a blank XNA Game project that references the content project. Then set up the project dependencies so the XNA Game will rebuild first if necessary. If you need to copy the output files around, perhaps do it as a post-build step?

    The sledgehammer option would be to create a custom MSBuild file that does exactly what you want.