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:
Here is what I see in the solution explorer when I look for the file:
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:
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.
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’.