summaryrefslogtreecommitdiff
path: root/modules/mono/editor/GodotTools/GodotTools.OpenVisualStudio/Program.cs
diff options
context:
space:
mode:
authorDensorius <d_angevaare@live.nl>2022-02-04 00:06:53 +0100
committerDensorius <d_angevaare@live.nl>2022-02-04 00:34:02 +0100
commit9ea0508d35fa747b81b327e41969f926633d768f (patch)
treea58470e534e6f34a019c04427dcf8d8d946c32ea /modules/mono/editor/GodotTools/GodotTools.OpenVisualStudio/Program.cs
parentf8f19b313d62b707467c54d245b9c3e0ad53f34f (diff)
Add Visual Studio 2022 support with fallback to 2019
Diffstat (limited to 'modules/mono/editor/GodotTools/GodotTools.OpenVisualStudio/Program.cs')
-rw-r--r--modules/mono/editor/GodotTools/GodotTools.OpenVisualStudio/Program.cs23
1 files changed, 21 insertions, 2 deletions
diff --git a/modules/mono/editor/GodotTools/GodotTools.OpenVisualStudio/Program.cs b/modules/mono/editor/GodotTools/GodotTools.OpenVisualStudio/Program.cs
index ce2b378623..f29b339c0e 100644
--- a/modules/mono/editor/GodotTools/GodotTools.OpenVisualStudio/Program.cs
+++ b/modules/mono/editor/GodotTools/GodotTools.OpenVisualStudio/Program.cs
@@ -47,9 +47,13 @@ namespace GodotTools.OpenVisualStudio
if (dte == null)
{
// Open a new instance
+ dte = TryVisualStudioLaunch("VisualStudio.DTE.17.0");
- var visualStudioDteType = Type.GetTypeFromProgID("VisualStudio.DTE.16.0", throwOnError: true);
- dte = (DTE)Activator.CreateInstance(visualStudioDteType);
+ if (dte == null)
+ {
+ // Launch of VS 2022 failed, fallback to 2019
+ dte = TryVisualStudioLaunch("VisualStudio.DTE.16.0");
+ }
dte.UserControl = true;
@@ -133,6 +137,21 @@ namespace GodotTools.OpenVisualStudio
return 0;
}
+ private static DTE TryVisualStudioLaunch(string version)
+ {
+ try
+ {
+ var visualStudioDteType = Type.GetTypeFromProgID(version, throwOnError: true);
+ var dte = (DTE)Activator.CreateInstance(visualStudioDteType);
+
+ return dte;
+ }
+ catch (COMException)
+ {
+ return null;
+ }
+ }
+
private static DTE FindInstanceEditingSolution(string solutionPath)
{
if (GetRunningObjectTable(0, out IRunningObjectTable pprot) != 0)