Publishing causes my content files to be split

I have been unable to use the MGCB to build my XML files (still don’t know why), but I have been able to get round it by using the IntermediateSerializer.

I have all of my Content in the same place (specifically under the main Content folder that comes by default with a new Monogame project). However, when I publish my game, the XML files and the files I have built with the MGCB are outputted in separate folders, meaning I cannot load the XML files using the Content.RootDirectory.

I suspect this happens because I do not build the XML files with the MGCB, but how do I get around this?

(Code, demonstration of the problem etc. all available, but this could just be an options problem so I have left them out for now)

Could you show us your csproj file? We’ll have to see how your project is setup before we can suggest why it might not be working as expected.

Of course, here is the .csproj (sorry it’s so long):

`<?xml version="1.0" encoding="utf-8"?>


Debug
x86
8.0.30703
2.0
{B285543F-A717-4F8F-8915-1D06CF8B2BF4}
WinExe
Properties
SpaceCardGame
SpaceCardGame
512
Windows


$(MSBuildProgramFiles32)
$(MSBuildExtensionsPath)
v4.5



x86
true
full
false
bin\Windows\Debug</OutputPath>
DEBUG;TRACE;WINDOWS
prompt
4
false


x86
pdbonly
true
bin\Windows\Release</OutputPath>
TRACE;WINDOWS
prompt
4
false


Icon.ico






















































































$(MonoGameInstallDirectory)\MonoGame\v3.0\Assemblies\Windows\MonoGame.Framework.dll






PreserveNewest
Designer


PreserveNewest


PreserveNewest


PreserveNewest


PreserveNewest


PreserveNewest


PreserveNewest


PreserveNewest


PreserveNewest


PreserveNewest


PreserveNewest


PreserveNewest


PreserveNewest


PreserveNewest


PreserveNewest


PreserveNewest


PreserveNewest


PreserveNewest


PreserveNewest


PreserveNewest


PreserveNewest


PreserveNewest


PreserveNewest


PreserveNewest


PreserveNewest


PreserveNewest


PreserveNewest


PreserveNewest


PreserveNewest


PreserveNewest


PreserveNewest


PreserveNewest


PreserveNewest


PreserveNewest


PreserveNewest


PreserveNewest



PreserveNewest


PreserveNewest


PreserveNewest


PreserveNewest


PreserveNewest


PreserveNewest


PreserveNewest


PreserveNewest


PreserveNewest


PreserveNewest


PreserveNewest


PreserveNewest


PreserveNewest


PreserveNewest


PreserveNewest


PreserveNewest


PreserveNewest


PreserveNewest


PreserveNewest


PreserveNewest


PreserveNewest


PreserveNewest


PreserveNewest


PreserveNewest


PreserveNewest


PreserveNewest



PreserveNewest


PreserveNewest


PreserveNewest


PreserveNewest


PreserveNewest


PreserveNewest


PreserveNewest


PreserveNewest


PreserveNewest


PreserveNewest


PreserveNewest
Designer


PreserveNewest


PreserveNewest


PreserveNewest


PreserveNewest


PreserveNewest


PreserveNewest


PreserveNewest


PreserveNewest


PreserveNewest


PreserveNewest


PreserveNewest


PreserveNewest


PreserveNewest


PreserveNewest


PreserveNewest


PreserveNewest


PreserveNewest


PreserveNewest


PreserveNewest


PreserveNewest


PreserveNewest


PreserveNewest


PreserveNewest


PreserveNewest


PreserveNewest


PreserveNewest


PreserveNewest


PreserveNewest


PreserveNewest


PreserveNewest


PreserveNewest


PreserveNewest


PreserveNewest


PreserveNewest


PreserveNewest


PreserveNewest


PreserveNewest


PreserveNewest


PreserveNewest


PreserveNewest


PreserveNewest


PreserveNewest


PreserveNewest


PreserveNewest


PreserveNewest


PreserveNewest


PreserveNewest


PreserveNewest


PreserveNewest


PreserveNewest


PreserveNewest


PreserveNewest


PreserveNewest


PreserveNewest


PreserveNewest


PreserveNewest


PreserveNewest


PreserveNewest


PreserveNewest


PreserveNewest









PreserveNewest




{ed8a2787-963c-45ce-9405-d4a031b3a977}
2DEngineData


{b56f5aa9-69a8-454a-9ee5-a815735804b7}
2DEngine


{b0f38153-06f2-4085-ac2a-e0069e00808c}
CardGameEngineData


{df91d356-e1b8-4dba-96e6-95a95fbeaa89}
CardGameEngine


{abb06fbe-bad5-424a-8b9b-c1548a1a4b76}
SpaceCardGameData




`

You appear to have all of your non-XML assets included in the csproj as Content with Copy if Newer, as well as the output from the Content project being built and copied to the output by the MonoGame.Content.Builder.targets file. You don’t need to have the png, jpg, fx, and spritefont files in the csproj file.

Many thanks for your reply.

With regards to the png etc. files, I set them as Content and Copy If Newer following the documentation on adding content on the Monogame website:

http://www.monogame.net/documentation/?page=Using_The_Pipeline_Tool

For me, it seems like the problem is caused by the fact I am currently unable to build my XML files with the MGCB. Everything else I can, so it feels like during publishing the content built with the MGCB is added in one place and the other content is added in another.

In fact, when I installed the game on my computer, I went to the files in my AppData etc. and found one folder with all the content except my XML and another with all of my content completely. However, the ContentManager’s root directory was set to the directory without the XML rather than the one with all the Content.

You misread the docs. They say you should use copy if newer on the xnb files. Though since you use an mgcb file with the build action set to MonoGameContentReference it will generate xnb’s in your output folder for the files added as content, so you should keep the copy action at Do not copy for those.

You’re right that I misread the docs, so I changed all of my content files to be Do not copy. However, the same thing happened when I published. I tried cleaning my Debug folder in ‘bin’, but then the assets were no longer copied across when I ran the program.

From what you’ve said, it seems like I should mark them as Do Not Copy so I am quite confused as to what I need to do now.

Are they copied to a different location or not at all? Maybe the output directory in your mgcb is wrong.

Can you show us the directory structure in the output directory? You’ve said they’re different directories, but you haven’t showed us what those directories are. Also, seeing the MGCB file might be useful. The non-XML assets you have in the csproj that you have now marked as “Do Not Copy” can be removed from the csproj completely. They do not need to be there.