Mgcb Editor won't open file because the path is corrupted

MGCB Editor will not open the content file in VS2022 either by double-click or in the editor screen because the path it uses is corrupted. Won’t bore you with how it got corrupted by moving projects from previous versions to 2022. Have uninstalled the extension and reinstalled still uses the old path. Is there a config file that the editor uses for this path? How can I reset the path?

Hi @lionelthomas,

I’m wondering since you said you’re coming from a previous version of VS to VS 2022 if that also means you’re coming from a previous version of MonoGame.

If so, the problem may be that, previously the MGCB Editor was installed as a global tool, which is no longer the case. If so, this reply I posted here may be able to help Can't open MGCB editor - #7 by Aristurtle

1 Like

Thank you so much for your reply. But frankly, I’m lost. There is so much I don’t know how to do. I’ve been trying to move all my old code to VS 2022. Most of my projects are from 2017 or older and I have not used templates. Should I start by creating projects from templates and then adding my code. I don’t have any configs in my projects. Hope you can help.

1 Like

Ah ok, if you’re coming from VS 2017 or older, those projects are most likely older 3.7 MonoGame projects. So a little backstory to get you caught up

How 3.7 And Earlier Worked

In the previous versions of MonoGame, there was actually an installer that you downloaded. This installed the various templates that are used by Visual Studio, as well as a number of supporting libraries and files needed for the MonoGame projects. This also installed the “Pipeline Tool” as it was known at the time.

How 3.8.1 And Onwards Works

MonoGame is no longer something you install locally on your computer. Instead, it’s various project templates used to create a new project and the actual MonoGame bits are now distributed via NuGet packages. This includes the “Pipeline Tool” which is now called the MGCB Editor.

Converting From Older Versions To Current

Here is the official documentation https://docs.monogame.net/articles/migrate_37.html however, it just simply states

WindowsDX and DesktopGL templates now use SDK-style projects. To migrate old projects we recommend creating a new project with the 3.8+ templates and copying the csproj to your project folder. Make sure you back up your old project.

So with that out of the way, I’ll list some steps you should probably go through to just ensure you’re starting from a fresh point.

  1. Uninstall the Visual Studio Extension. This is probably not necessary, but we want to ensure a fresh starting point.
  2. Check under your add/remove programs in windows for the old MonoGame installed stuff. Uninstall all of it, it’s no longer needed. (If you do find you ever need to reinstall the older versions you can find them on the Releases page
  3. Just to be sure, make sure the mgcb-editor was never installed as a global tool by running the following command in a command line window dotnet tool uninstall mgcb-editor -g. If it finds nothing to uninstall, that’s fine, we just want to ensure that it’s not installed as a global tool.
  4. Open Visual Studio, when presented with the option to open an existing project/solution/folder/whatever, just click the “continue without code” link thing. Now, reinstall the MonoGame extension in Visual Studio. This is going to require you to restart visual studio

After completing the above steps, you should now be at a fresh point to create MonoGame 3.8.1.303 (current version as of this post) projects. You should try creating just a brand new one and running it to ensure it builds correctly and you get the standard cornflour blue window.

Having the extension installed, and after ensuring all the things we did above, you should be able to double click the Content.mgcb file in Visual Studio and it open in the MGCB Editor as expected.

Now, to convert your old projects to the new format, my absolute best suggestion would be to create a brand new MonoGame 3.8.1.303 project, then copy your code from the old project to the new one. There should be no major issues doing this

The New MGCB Editor

As I mentioned previously, older MonoGame actually installed the “Pipeline Tool” as a program on your computer. Starting with MonoGame 3.8, it is now called the MGCB Editor and it is included in projects as a dotnet tool If you’re unfamilar with dotnet tools you can read more about them here. The tl;dr is that they are special NuGet packages that are tools that can be executed from the command line. So you no longer need it installed, it’s just included as a NuGet package.

With the Visual Studio extension, double clicking should open the Content.mgcb file with the MGCB Editor for you. If this does not happen, then you can follow the steps I linked in the previous post to ensure everything is working correctly.

2 Likes

Thank you again. This is very helpful. Knowing that Monogame setup now works differently helps a lot. I built a small test project game from the tutorial and it works fine. Then I have started to build my game project as you have suggested. The MGCB Editor works fine by clicking the file. Now I need to include the Bmfonts from Monogame. extended unless there is a better option. A little bit confused on references. One of my projects is a library project. Thanks again for your help.

2 Likes

Still need help! Trying to work with fonts. Imported a project from https://www.southseagamesgurus.co.uk/. Works great! Using VS2022 and MGCB 3.7.1.189. I followed the migration instructions to upgrade to 3.8 and now get Error MSB3073 MGCB exited with code 4. What am I missing?

Probably the string literal thingy, check your username for a gap in the folder structure… think this was rectified in 3.8.1.303

Im going to guess that when you say it exited with code 4, that this is when you do a project build?

If so, during a project build, the MonoGame.Content.Builder.Task performs a content build using the MGCB, but uses the /quiet flag so it doesnt actually output the specific error.

What happens if you open the MGCB Editor and do a build from within that? If it still errors you should be able to expand the asset that errors to see the actual exception message.

2 Likes

Thank you for your suggestion. Here is what I did.
The content builder builds fine but doesn’t create the effect files correctly. Removing the .fx files from the independent build and copying .fx files from the previous version the error 4 on build disappears. Then when I run, this statement FontShader = Content.Load(@“Fonts\SDFFont2”); gives an error System.Exception: ‘This MGFX effect is for an older release of MonoGame and needs to be rebuilt.’
I’m now confused when the new rebuilt versions give an exit 4.
Hope I’m explaining this right.

Finally got it to work! Started from the beginning and used the MonoGame Windows Desktop Application template. Then added the files one by one. Copied the txt files on compile. Resolved the files not found references. Then the build worked.
Not sure if this would work on Cross-Platform.
Error diagnostics for MGCB tool need to be much, much better. Exit 1 and Exit 4 is not acceptable.
Upgrade procedures can really improve. It is not just a matter of references. “Use a supplied template” is not sufficient.
Let me know how I can help improve this process.

1 Like