Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[3.x] Avoid modifying csproj globbing includes #54262

Merged
merged 1 commit into from
Oct 26, 2021
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,19 @@ public static void RenameItemInProjectChecked(string projectPath, string itemTyp
if (item == null)
return;

// Check if the found item include already matches the new path
var glob = MSBuildGlob.Parse(item.Include);
if (glob.IsMatch(normalizedNewInclude))
return;

// Otherwise, if the item include uses globbing it's better to add a new item instead of modifying
if (!string.IsNullOrEmpty(glob.WildcardDirectoryPart) || glob.FilenamePart.Contains("*"))
{
root.AddItem(itemType, normalizedNewInclude.RelativeToPath(dir).Replace("/", "\\"));
root.Save();
return;
}

item.Include = normalizedNewInclude.RelativeToPath(dir).Replace("/", "\\");
root.Save();
}
Expand Down Expand Up @@ -315,7 +328,7 @@ void RemoveElements(IEnumerable<ProjectElement> elements)

// Godot API References

var apiAssemblies = new[] {ApiAssemblyNames.Core, ApiAssemblyNames.Editor};
var apiAssemblies = new[] { ApiAssemblyNames.Core, ApiAssemblyNames.Editor };

RemoveElements(root.ItemGroups.SelectMany(g => g.Items)
.Where(i => i.ItemType == "Reference" && apiAssemblies.Contains(i.Include)));
Expand Down