Monogame: Can't set MGCB Editor as default in VS 2019

Created on 12 Aug 2020  路  23Comments  路  Source: MonoGame/MonoGame

Quite a strange issue, tldr. you can't set MGCB Editor as default unless you specify the full path to it.

@jnoyola @Jjagg You guys are Windowsy guys, can't we use the old registry trick during register to make it the default editor for .mgcb files in VS 2019?

MGCB Editor

All 23 comments

Sounds like a VS bug. Should be logged with them if it isn't already.

What about the registry trick?

... Withdrawing unhelpful information ...

When I had tried the registry trick, it didn't work for me with VS 2019 so I left it out. That being said, I didn't confirm that the same thing worked with VS 2017, so it's possible I made a mistake somewhere.

you can't set MGCB Editor as default unless you specify the full path to it

Where are you trying to set it? Are you referring to the CurrentSettings.vssettings file? Requiring an absolute path makes sense to me -- what would you want it to be relative to, the VS executable in Program Files?

... Withdrawing unhelpful information ...

It's possible. You could try right clicking on the folder or exe, opening properties, and see if there's an "Unblock" checkbox at the bottom. I've had that issue while using PowerShell to load DLLs downloaded from nuget packages before.

... Withdrawing unhelpful information ...

... Withdrawing unhelpful information ...

The exe in the dotnet-mgcb-editor folder is the one you're expecting that is built from our csproj and distributed in the nuget package.

The exe in the .dotnet\tools folder is a wrapper that dotnet generates when you install a global tool. This allows dotnet to only add that .dotnet\tools folder to your PATH, rather than updating your PATH every time you install/uninstall a global tool. It simply calls the real exe with any parameters.


So are you saying "open with" works only on the copy? That could be due to the security checkbox, since the original exe was downloaded from the internet, but the copy was created locally. I'd say check the properties for the "Unblock" checkbox and then see if it works on the original.

... Withdrawing unhelpful information ...

Ok, I'm not understanding the problem then. How would you expect to "Open With" the MGCB Editor without browsing into its folder? Like what is the alternative to using this absolute path?

... Withdrawing unhelpful information ...

To get one thing straight, the current register command only registers it to open from Windows. It doesn't touch Visual Studio.

Now, you're saying upon doing that, the exe shows up in the "added tools list" where it doesn't work, but using "open with" it does work. What is the "added tools list"? Since registering currently only registers in Windows, not in VS, it sounds like what you're talking about might be expected behavior and entirely different from what Harry is talking about.

@harry-cpp could you please describe what you're talking about? Because I'm lost.

... Withdrawing unhelpful information ...

I remember this bug appearing after upgrading both Monogame (to 3.7.???) and Visual Studio 2019. Might be a VS bug tbh.

@willmotil I don't want to sound mean, but you are really not helping in resolving this issue, please don't try to add random topics / assumptions in here.

@jnoyola After doing the --register command, Open With dialog in VS showed me a "mgcb-editor-wpf" option, which did not work if you tried setting it as default, however you could still open using it by not setting it as the default option.

Yes, probably a bug in Visual Studio, but I would like to workaround it if possible.

I see. Is VS registration something we want to accomplish programmatically anyway? It might be less important whether the "Open With" dialog works if we can register in VS ourselves. I think we should try either the registry (which it now sounds like multiple people are saying this doesn't work in VS 2019) or the CurrentSettings.vssettings file.

Withdrawing ... from topic.

So, an update to my side:
--> Before Monogame 3.8 I had to manully start the mgcb-editor either using the console, or either using Open As -> MGCB Editor. I've noticed this behiavour since a Visual Studio update.

--> In Monogame 3.8 I seem unable to even open MGCB-Editor in VS, even if trying to open manually in VS. Perhaps I have to actually use some command line arguments? The only way I can use the content editor is running CMD and writing mcgb-editor and then manually opening the content file.

And yes, I've tried to launch MGCB using this command in the windows terminal (classic command prompt) :
mgcb-editor "<complete path>"
For some reason, I either I'm unable to use some tools properly, OR this is also a bug related to command line arguments?

Just a guess, from what I've tried so far. I'll provide further updates if I will find something.

The bug is in Visual Studio, its unable to set an application thats default for an extension as the default application unless you manually specify the path to the .exe. You can try this with a .png file, just try setting the default editor for it to the default system application in VS and it will still open it in its own internal editor.

The solution to this whole problem is either to write an editor extension or maybe CurrentSettings.vssettings that @jnoyola spoke about earlier.

I am able to set the editor as the default using "Open With...", but it still only opens a text version of the MGCB file when I double click it in the solution explorer. However, if I double click the editor in the selection of options in the "Open With..." dialog, that opens up the editor with the MGCB file opened in it.

Not sure that is the root of the issue @harry-cpp, I have .mgcb files defaulted to the MGCB-Editor and have "set as default" the mgcb editor in VS.

However, since the 3.7 upgrade, every time I double click on the content file in Visual Studio, I still get the text editor. VS doesn't seem to be respecting the default for some reason.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dazinator picture dazinator  路  5Comments

griseus picture griseus  路  5Comments

Grabiobot picture Grabiobot  路  5Comments

tomspilman picture tomspilman  路  4Comments

Legendree picture Legendree  路  3Comments