From 3a1655764236633b7512debcec8d2e9a030134bc Mon Sep 17 00:00:00 2001 From: Raul Santos Date: Fri, 25 Mar 2022 16:45:25 +0100 Subject: [PATCH] Avoid modifying csproj globbing includes on remove Check if the found globbing include already matches the given path on removing scripts to avoid modifying users' csproj files. (cherry picked from commit 3086d7c035a102cf1e33f0ce62bf2b9942b5cb4f) --- .../GodotTools.ProjectEditor/ProjectUtils.cs | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/modules/mono/editor/GodotTools/GodotTools.ProjectEditor/ProjectUtils.cs b/modules/mono/editor/GodotTools/GodotTools.ProjectEditor/ProjectUtils.cs index 0a949e5e63f..dbeafd0f676 100644 --- a/modules/mono/editor/GodotTools/GodotTools.ProjectEditor/ProjectUtils.cs +++ b/modules/mono/editor/GodotTools/GodotTools.ProjectEditor/ProjectUtils.cs @@ -108,8 +108,22 @@ namespace GodotTools.ProjectEditor var normalizedInclude = include.NormalizePath(); - if (root.RemoveItemChecked(itemType, normalizedInclude)) - root.Save(); + var item = root.FindItemOrNullAbs(itemType, normalizedInclude); + + // Couldn't find an existing item that matches to remove + if (item == null) + return; + + var glob = MSBuildGlob.Parse(item.Include); + + // If the item include uses globbing don't remove it + if (!string.IsNullOrEmpty(glob.WildcardDirectoryPart) || glob.FilenamePart.Contains("*")) + { + return; + } + + item.Parent.RemoveChild(item); + root.Save(); } public static void RenameItemsToNewFolderInProjectChecked(string projectPath, string itemType, string oldFolder, string newFolder)