Pipeline Confusion

Up until now I have stayed away from the pipeline tool because I’ve found it a bit buggy and unpredictable. Now with 3.6 it looks as if (without the stream thing) I’m going to have to go this way, which isn’t such a bad thing.

But it continues to confuse me.

I have an mgbc file in my content folder in my application, I’ve added pictures, but if the Content.Load no longer exists,how do I reference the textures in code?

If I search for3.6 and pipeline, all I can find are the posts about stream for raw graphics or old pipeline tutorials that rely on Content.Load.

Could someone please point me towards the documentation (whatever it be) that explains the new way to do things?

Thanks.

The file I’m testing with at the moment builds the xnb files and puts them in a ‘bin’ folder off the content folder, is this correct?

I remember on one project a while ago I was using the tool to create the xnb’s then had to manually copy the built files into a different directory somewhere else, is this still the same? It isn’t a very clean way to do things!

And why wont the pipeline tool allow me to select ‘Copy to content folder’ when I’m importing graphics? (multiple files)

And why does the tool rename some of my .png files as .pr files?

The tool does seem to be still a little buggy. But apart from that the most important thing is being able to get assets back into the game. So once the xnb’s are built, where should they be in the directory structure of the game? Do they need to be copied to the bin/platform/debug folders as I’ve had to before? Or is this different? and do I still use Content.Load?

http://rbwhitaker.wikidot.com/monogame-managing-content

That’s what I’ve followed, in the past and today. The files don’t end up where the running exe expects to find them. So where should the xnb files be on a windows hard drive to work?

If you have some concrete issues, please mention them or open an issue on GitHub. But do try to learn how to use it before doing that. I find the Pipeline Tool pretty stable and easy to use.

Content.Load no longer loads raw assets, but it should be used to load .xnb files. It’s not deprecated or anything.

The Pipeline Tool is a standalone thing, so when it builds assets it puts them (by default) in a bin folder where the .mgcb file is located. The .xnb files still need to be copied to your project bin folder somehow so you can access them in your game. However MonoGame offers an easy solution for that. MonoGame template projects import a .targets file in the .csproj that defines a build action for .mgcb files. It’s called MonoGameContentReference. When you set that on your .mgcb the assets it contains will automatically be built (if necessary) and copied to your project bin folder when you build your project. The location of the assets in the project bin folder is the same as the relative location of the .mgcb file in your project. I.e. if your .mgcb file is at {ProjectRoot}/Content/Content.mgcb then the MonoGameContentReference Build Action will copy the built .xnb files to {ProjectBin}/Content/{AssetLocation}.
A ContentManager has a property RootDirectory which - in the MG templates - is set to “Content” because the .mgcb file in the templates is in the {ProjectRoot}/Content folder.

So just a quick rundown of how to use the Pipeline Tool to load an image:

  • Start a new project from one of the MG templates
  • Open the .mgcb file using the Pipeline Tool
  • Add your image.png and save the .mgcb file
  • In you project load the image by doing var myImage = Content.Load<Texture2D>("image");
  • Build your project. This will do the other steps for you automatically because of the MonoGameContentReference build action.
    • The .mgcb file will be built. This will produce the .xnb for the image.
    • The .xnb file will be copied to your project output dir

This stuff is all explained in the docs by the way: http://www.monogame.net/documentation/?page=Using_The_Pipeline_Tool

EDIT
Just to clarify where a ContentManager expects content to be:
When loading a file called “image” (Content.Load<Texture2D>("image")) the ContentManager looks for the file at WorkingDir/RootDirectory/image.xnb. WorkingDir is the directory of your game executable, so that would be the bin/Platform/Debug/ folder usually. RootDirectory is the property of ContentManager. So when you start from a template and call Content.Load<Type>("fileName") the path is WorkingDir/Content/filename.xnb.

1 Like

I understand how the Pipeline tool is meant to work, and I have to admit I haven’t used version 3.6 much yet, maybe the problems I’ve encountered are no longer.

But I still don’t understand where my xnb files should end up. As an example my application is in: c:\VB\ProjectName

The build folder for this is C:\ProjectName\Bin\Windows\Debug

So where exactly in this structure do they need to be? I’ve tried copying them into a bin\Contents and just a Contents folder in each step of the tree and nowhere works.

And to further compound the problem I’m using VB2015, there’s never been an official template and I don’t have a .targets file.

Furthermore, for that matter with 3.6 installed I don’t see any Monogame projects in the New menus.

But first things first, I need to get these bloomin xnb’s in the right place!

Thanks so far Jjagg.

Been a while since I’ve done any monogame stuff, but this might help.

In your “C:\VB\ProjectName” folder you should have a folder named “Content” and in there you should be the Content.mgcb file.

When you open the above mgcb file with the pipeline tool you can create folders like “images” or “Fonts” these will then appear as sub folders

C:\VB\ProjectName\Content\Images
C:\VB\ProjectName\Content\Fonts

In the above folders will be your PNG etc files (which you add though the Pipeline tool.

After you have added the files, you then click the Build/Rebuild button in the pipeline, this will then create a subfolder called BIN and will place the XNB files in there:

C:\VB\ProjectName\Content\bin\Windows\Images

Now go back to Visual studio, and when you BUILD in VS you will end up with the following paths:

C:\VB\ProjectName\bin\debug\mainApp.exe
C:\VB\ProjectName\bin\debug\Content\Images*.xnb
C:\VB\ProjectName\bin\debug\Content\Fonts*.xnb

Hope this helps.

I recommend starting from a C# template and replacing the Game1.cs file with a vb class.

Like I said, the ContentManager looks for the file at the ContentManager looks for the file at WorkingDir/RootDirectory/filename.xnb. If you have your .xnb’s in C:\ProjectName\bin\Windows\Debug\Content make sure you set the RootDirectory property of the ContentManager you’re using to “Content”.
To see where the ContentManager is looking for the assets, check the inner exception when the application breaks when trying to load something.