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.
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
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:
Create a Shared Project “GameContent”
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”
As mentionned above make sure the Content.mgcb file is set the build action to "MonogameContentReference "
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.
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
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?