Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions GodotAddinVS/GodotPackage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ namespace GodotAddinVS
[ProvideOptionPage(typeof(GeneralOptionsPage),
"Godot", "General", 0, 0, true)]
[ProvideMenuResource("Menus.ctmenu", 1)]
[ProvideAutoLoad(UIContextGuids80.NoSolution, PackageAutoLoadFlags.BackgroundLoad)]
public sealed class GodotPackage : AsyncPackage
{
/// <summary>
Expand Down
13 changes: 13 additions & 0 deletions GodotAddinVS/GodotSolutionEventsListener.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
using System.ComponentModel.Design;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using EnvDTE;
using GodotAddinVS.Debugging;
using GodotAddinVS.GodotMessaging;
using GodotTools.IdeMessaging;
using GodotTools.IdeMessaging.Requests;
using Microsoft.VisualStudio;
using Microsoft.VisualStudio.Shell;
using Microsoft.VisualStudio.Shell.Interop;

Expand Down Expand Up @@ -67,6 +69,17 @@ private static IEnumerable<Guid> ParseProjectTypeGuids(string projectTypeGuids)
private static bool IsGodotProject(IVsHierarchy hierarchy)
{
ThreadHelper.ThrowIfNotOnUIThread();

hierarchy.GetProperty(VSConstants.VSITEMID_ROOT, (int)__VSHPROPID.VSHPROPID_ExtObject, out var objProj);

const string csProjectKind = "{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}";
if (objProj is Project project && project.Kind == csProjectKind)
{
string csprojContent = File.ReadAllText(project.FileName);
Match match = Regex.Match(csprojContent, @"<Project\s*Sdk=""Godot.NET.Sdk/.[^>]*>");
return match.Success;
}

return hierarchy is IVsAggregatableProject aggregatableProject &&
aggregatableProject.GetAggregateProjectTypeGuids(out string projectTypeGuids) == 0 &&
ParseProjectTypeGuids(projectTypeGuids)
Expand Down