Skip to content

Commit ebc9844

Browse files
committed
Make GodotTools.OpenVisualStudio to support higher versions of Visual Studio
1 parent 3d91a48 commit ebc9844

File tree

1 file changed

+17
-12
lines changed
  • modules/mono/editor/GodotTools/GodotTools.OpenVisualStudio

1 file changed

+17
-12
lines changed

modules/mono/editor/GodotTools/GodotTools.OpenVisualStudio/Program.cs

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -46,19 +46,24 @@ private static int Main(string[] args)
4646

4747
if (dte == null)
4848
{
49-
// Open a new instance
50-
dte = TryVisualStudioLaunch("VisualStudio.DTE.17.0");
49+
// Try starting from the higher version
50+
string[] vsVersions = {
51+
"VisualStudio.DTE.18.0",
52+
"VisualStudio.DTE.17.0",
53+
"VisualStudio.DTE.16.0"
54+
};
55+
56+
foreach (string vsVersion in vsVersions)
57+
{
58+
dte = TryVisualStudioLaunch(vsVersion);
59+
if (dte != null)
60+
break;
61+
}
5162

5263
if (dte == null)
5364
{
54-
// Launch of VS 2022 failed, fallback to 2019
55-
dte = TryVisualStudioLaunch("VisualStudio.DTE.16.0");
56-
57-
if (dte == null)
58-
{
59-
Console.Error.WriteLine("Visual Studio not found");
60-
return 1;
61-
}
65+
Console.Error.WriteLine("Visual Studio not found");
66+
return 1;
6267
}
6368

6469
dte.UserControl = true;
@@ -189,7 +194,7 @@ private static int Main(string[] args)
189194
continue;
190195

191196
// The digits after the colon are the process ID
192-
if (!Regex.IsMatch(ppszDisplayName, "!VisualStudio.DTE.1[6-7].0:[0-9]"))
197+
if (!Regex.IsMatch(ppszDisplayName, "!VisualStudio.DTE.1[6-8].0:[0-9]"))
193198
continue;
194199

195200
if (pprot.GetObject(moniker[0], out object ppunkObject) == 0)
@@ -292,4 +297,4 @@ private interface IOleMessageFilter
292297

293298
#endregion
294299
}
295-
}
300+
}

0 commit comments

Comments
 (0)