From c4d7ac7372464a0875acd7a13c6dc41838757c6e Mon Sep 17 00:00:00 2001 From: Matt Ward Date: Fri, 13 Apr 2018 17:38:54 +0100 Subject: [Core] Fix MSBuild items added for globs with link metadata A project containing the following MSBuild file globs would have extra MSBuild items added when the project file was saved. %(RecursiveDir)%(Filename)%(Extension) On saving the project Compile Update items would be added for each file included by the file glob. Class1.cs Fixes VSTS #527721 - Overriding globs --- .../MonoDevelop.Projects.MSBuild/MSBuildValueType.cs | 5 +++++ main/src/core/MonoDevelop.Core/MonoDevelop.Projects/Project.cs | 2 ++ 2 files changed, 7 insertions(+) (limited to 'main/src/core') diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.MSBuild/MSBuildValueType.cs b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.MSBuild/MSBuildValueType.cs index 2e548ef0ed..32fa107420 100644 --- a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.MSBuild/MSBuildValueType.cs +++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.MSBuild/MSBuildValueType.cs @@ -45,6 +45,7 @@ namespace MonoDevelop.Projects.MSBuild class PathValueType: MSBuildValueType { static readonly char [] pathSep = { '\\' }; + static string currentDirectoryPrefix = @".\"; public override bool Equals (string ob1, string ob2) { @@ -52,6 +53,10 @@ namespace MonoDevelop.Projects.MSBuild return true; if (ob1 == null || ob2 == null) return string.IsNullOrEmpty (ob1) && string.IsNullOrEmpty (ob2);//Empty or null path is same thing + if (ob1.StartsWith (currentDirectoryPrefix, StringComparison.OrdinalIgnoreCase)) + ob1 = ob1.Substring (currentDirectoryPrefix.Length); + if (ob2.StartsWith (currentDirectoryPrefix, StringComparison.OrdinalIgnoreCase)) + ob2 = ob2.Substring (currentDirectoryPrefix.Length); return ob1.TrimEnd (pathSep) == ob2.TrimEnd (pathSep); } } diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/Project.cs b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/Project.cs index 81781f78c8..bba9a973a2 100644 --- a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/Project.cs +++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/Project.cs @@ -3823,6 +3823,8 @@ namespace MonoDevelop.Projects if (p2 == null || !p.ValueType.Equals (p.Value, p2.UnevaluatedValue)) { if (generateNewUpdateItem) continue; + if (p2?.UnevaluatedValue != null && p2.UnevaluatedValue.Contains ('%') && p.ValueType.Equals (p.Value, p2.Value)) + continue; if (updateItem == null) { updateItems = FindUpdateItemsForItem (globItem, item.Include).ToList (); updateItem = updateItems.LastOrDefault (); -- cgit v1.2.3 From db71cb635cb4d1a82bafaec63c65f1b935b80be8 Mon Sep 17 00:00:00 2001 From: Matt Ward Date: Fri, 13 Apr 2018 17:49:39 +0100 Subject: [Core] Rework fix for wildcard expanding on saving a project No need to evaluate the MSBuild item property since the evaluated property can be matched when the unevaluated property contains '%' characters. This is a re-work of the fix for VSTS #569295 - Projects that includes files using wildcards will expand (and remove) wildcards upon save --- main/src/core/MonoDevelop.Core/MonoDevelop.Projects/Project.cs | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) (limited to 'main/src/core') diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/Project.cs b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/Project.cs index bba9a973a2..2be59e7e93 100644 --- a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/Project.cs +++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/Project.cs @@ -3780,7 +3780,6 @@ namespace MonoDevelop.Projects { // Compare only metadata, since item name and include can't change - MSBuildEvaluationContext context = null; var n = 0; foreach (var p in item.Metadata.GetProperties ()) { var p2 = evalItem.Metadata.GetProperty (p.Name); @@ -3789,12 +3788,7 @@ namespace MonoDevelop.Projects if (!p.ValueType.Equals (p.Value, p2.UnevaluatedValue)) { if (p2.UnevaluatedValue != null && p2.UnevaluatedValue.Contains ('%')) { // Check evaluated value is a match. - if (context == null) { - context = new MSBuildEvaluationContext (); - context.InitEvaluation (MSBuildProject); - } - string value = context.Evaluate (p.UnevaluatedValue); - if (!p.ValueType.Equals (p.Value, value)) + if (!p.ValueType.Equals (p.Value, p2.Value)) return false; } else return false; -- cgit v1.2.3