[SOLVED] How to use same content in multiple projects?

At the moment I want to have a central place, where I can organize my content. So basically what would be nice, if I could have a project with all my content and then use this content also in other projects, which are also inside the same solution, as the content project.

This would be helpful, because then I would only have one version of shaders. If I would have the same shader copied around to multiple projects, it would be hard to keep them synchronized, as I then would have to edit the shader in multiple files parallel.

Is this possible?

I’ve been trying different things:

linking to files using the pipeline-tool, and referencing content from other projects through the solution explorer.

But I cant get it working. BUMP for better answer!

Until then, maybe github…? It has the pulling system etc, it might be worth looking into…

There are some issues with links in .mgcb, when those are fixed you can just have a central folder with these resources and add them as a link in the pipeline tool. Relevant issue: https://github.com/MonoGame/MonoGame/issues/5109

It’s possible. Create an .mgcb in the same folder as your assets. Then add this file as a link and set build action to MonoGameContentReference.

The project looks like this:

    <MonoGameContentReference Include="..\..\ChervilContent\Content.W10.mgcb">
    <MonoGameContentReference Include="..\..\..\StageLibraries\Chervil\ChervilStageContent\StageContent.W10.mgcb">
    <MonoGameContentReference Include="..\Chervil.Shared\Stages\HardHatZone.Assets\HardHatZone.W10.mgcb">
1 Like

I thought there were some issues with that too. https://github.com/MonoGame/MonoGame/pull/4997
This PR should fix them though

It works on my computer… :grin:


That was the thing I missed, I think. I will try it, thank you :slight_smile:

Finally I found some time to test it. It works as described by @nkast with adding the mgcb from another project as a linked file in visual studio solution explorer and then setting the linked mgcb files “Build Action” to “MonoGameContentReference”.


To share the same Content between projects, very easilly:

In Visual Studio 2015 there is a new project type called “Shared Project”, it’s a project type that doesn’t output anything by itself, but is used to be referenced from other regular projects, and is meant to be merged at build time with any project referencing it. Here is step by step:

  1. Create a Shared Project “GameContent”
  2. just like any monogame project, add a “Content” folder , add the mgcb file and the asset files. Using the property panel, set any file that needs to be copied to the output folder to “Copy If Newer”
  3. As mentionned above make sure the Content.mgcb file is set the build action to "MonogameContentReference "
  4. From your regular C# projects, “Add Reference…”, then you’ll see a Tab “Shared Project” and select the “GameContent” project.

Now any project referencing your Shared Project will have it’s own copy of the Contents.

That’s nice to know! Thank You!

I find this the easiest way to do cross platform development in MonoGame. Shared projects are great. There’s a template for a shared project in monodevelop but not in VS. Last time I set this up in VS I had to manually edit the shproj file to get the MonoGameContentReference build action set up. The nice thing with this setup is content is automatically built for the right platform if you set up your platform specific projects from templates

glad I could help :smile:

Can we get a [SOLVED] in the title? :wink:

Could you expand a bit on this?
I’m failing to get this working tonight

  • In VS 2017
  • Add a Shared Project.
  • Copy the Content.mgcb and /bin and /obj folders from an existing project to this projects folder.
  • Add an existing item, selecting that Content file.
  • It adds properly

The “Build Action” does not have a “MonogameContentReference”

I tried manually edting the .shpro file, but dont see an obvious place to add/modify the build action. My various attempts to do so cause VS to not load/Display the Content MGCB file.

This is pretty important for me to get going, as Im targeting both UWP and Regular Windows. So any help would be greatly appreciated.

Could you share your .projitems file and .shproj files for your shared project?