Content not found when I run my program

I am having an odd issue that suddenly just started. I am making a desktop application for windows.

When I add an image file using the MGCB file and successfully build it, I get an error when I run my project when it tries to load the image into a Texture2D:
running error

Here is what I see in the solution explorer when I look for the file:
not working project

I have a version of this that I made on the same computer a week ago that works, with exactly the same code, and the content added in exactly the same way using the MGCB. Here is what it shows in the solution explorer:
working project

It seems like the MGCB tool is not building the image (mgcontent and xnb files) into a ‘Content’ folder inside the ‘Windows’ folder anymore, which I assume is why it is not working.

All of my new projects that I create are doing this and I am getting the same errors when I try to load content.

Any ideas?

Hi there. In your solution you are having issues with, can you show us the content of your content.mgcb file?

Also can you screenshot your bin folder expanded out?

Hi @Steven_Aldworth, Welcome to the Community!

Have you seen this guide?

Adding Content | MonoGame

Hope this helps.

Happy Coding!

The error is correct. You’re just looking in the wrong place. The path in the error message is

X:\My Drive\ISC4U\MonoGame 1\ Mono Intro take 3\bin\Debug\net6.0-windows\Content\dino.xnb

You’re looking at the path

X:\My Drive\ISC4U\MonoGame 1\ Mono Intro take 3\Content\bin\Windows\Content\dino.xnb

which is a completely different path.

What do you see when you do a

dotnet build

from the root of your project?

1 Like

I found a solution. I just added another line to my MGCB file:
/outputDir:bin/$(Platform)/Content

I’m just not sure why it is all of a sudden requiring me to do this now. I have older projects that don’t require me to add this line.

I have read this guide yes. This issue just started happening to newer projects.

Yes, that is the issue. The MGCB tool puts the dino.xnb file in the folders:
X:\My Drive\ISC4U\MonoGame 1\ Mono Intro take 3\Content\bin\Windows\dino.xnb
and
X:\My Drive\ISC4U\MonoGame 1\ Mono Intro take 3\bin\Debug\net6.0-windows\dino.xnb

But when I try to load the content, the project is looking in the folders:
X:\My Drive\ISC4U\MonoGame 1\ Mono Intro take 3\Content\bin\Windows\Content\dino.xnb
and
X:\My Drive\ISC4U\MonoGame 1\ Mono Intro take 3\bin\Debug\net6.0-windows\Content\dino.xnb

I don’t know what is different, but now when I make new projects, the MGCB tool is no longer building the xnb files in the \Content folders.

I made a ‘fix’ by adding the line:
/outputDir:bin/$(Platform)/Content
to my MGCB file in the project. The odd thing is the older projects that werent having this issue don’t need this ‘fix’.