From c49f826d58c1fa625ebc85eea6d9b09a2ff0ff1f Mon Sep 17 00:00:00 2001 From: Davis Goodin Date: Mon, 5 Mar 2018 10:41:40 -0600 Subject: [PATCH 1/3] Update MSBuild from 15.3.409 to 15.5.180 --- src/SourceBrowser | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SourceBrowser b/src/SourceBrowser index 7c03e5a..f167770 160000 --- a/src/SourceBrowser +++ b/src/SourceBrowser @@ -1 +1 @@ -Subproject commit 7c03e5aa27d942720f8b4e2fdb810179f7e4a9ca +Subproject commit f1677702525220edb08a390efebb8e2c5dfd6e71 From 5c14eb7788db8c2f76f27f965a4431632de82834 Mon Sep 17 00:00:00 2001 From: Davis Goodin Date: Mon, 5 Mar 2018 17:29:55 -0600 Subject: [PATCH 2/3] Check out MSBuild repository at known good commit --- src/index/index.proj | 11 +++++++++-- src/index/repositories.props | 1 + 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/index/index.proj b/src/index/index.proj index 36f7aa6..9de987d 100644 --- a/src/index/index.proj +++ b/src/index/index.proj @@ -33,9 +33,16 @@ - git clone %(Repository.Url).git --depth 1 -b %(Branch) --single-branch %(LocalPath) + git clone %(Repository.Url).git -b %(Branch) --single-branch + $(CloneCommand) --depth 1 + $(CloneCommand) %(Repository.LocalPath) + + git -C %(Repository.LocalPath) checkout %(Repository.OldCommit) + + true - + + diff --git a/src/index/repositories.props b/src/index/repositories.props index a734738..fce4339 100644 --- a/src/index/repositories.props +++ b/src/index/repositories.props @@ -34,6 +34,7 @@ https://github.com/Microsoft/msbuild master + 91c86a746b312fce1aba31f8fb8540e949c11a01 build/**/*.csproj; build/**/*.vbproj; From b20907c858656838c85112a73770555295f1eafc Mon Sep 17 00:00:00 2001 From: Davis Goodin Date: Thu, 8 Mar 2018 16:12:22 -0600 Subject: [PATCH 3/3] Use CreateItem task instead of GetFiles Remove reflection-based GetFiles method lookup and invocation. --- .../SelectProjects.cs | 33 +++++++++---------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/src/Microsoft.SourceIndexer.Tasks/SelectProjects.cs b/src/Microsoft.SourceIndexer.Tasks/SelectProjects.cs index 9e058f5..145b912 100644 --- a/src/Microsoft.SourceIndexer.Tasks/SelectProjects.cs +++ b/src/Microsoft.SourceIndexer.Tasks/SelectProjects.cs @@ -1,9 +1,9 @@ -using System; +using System; using System.Collections.Generic; using System.IO; using System.Linq; -using System.Reflection; using Microsoft.Build.Framework; +using Microsoft.Build.Tasks; using Microsoft.Build.Utilities; namespace Microsoft.SourceIndexer.Tasks @@ -30,25 +30,24 @@ public override bool Execute() } } - private static Type FileMatcher { get; } = Type.GetType("Microsoft.Build.Shared.FileMatcher, Microsoft.Build.Tasks.Core, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"); - - private static Func GetFiles { get; } = - GetGetFilesFunction(); - - private static Func GetGetFilesFunction() + private string[] GetFiles(string localPath, string glob) { - var func14 = FileMatcher.GetMethod("GetFiles", BindingFlags.NonPublic | BindingFlags.Static, null, new[] { typeof(string), typeof(string) }, new ParameterModifier[0]); - if (func14 != null) + var createItemTask = new CreateItem { - return (Func)func14.CreateDelegate(typeof(Func)); - } - var func15 = FileMatcher.GetMethod("GetFiles", BindingFlags.NonPublic | BindingFlags.Static, null, new[] { typeof(string), typeof(string), typeof(IEnumerable) }, new ParameterModifier[0]); - if (func15 != null) + BuildEngine = BuildEngine, + Include = new[] + { + new TaskItem(Path.Combine(localPath, glob)) + } + }; + + if (!createItemTask.Execute()) { - var f = (Func, string[]>)func15.CreateDelegate(typeof(Func, string[]>)); - return (a, b) => f(a, b, Enumerable.Empty()); + throw new Exception( + $"Failed to create items with localPath '{localPath}', glob '{glob}'"); } - throw new MissingMethodException("Could not find FileMatcher.GetFiles"); + + return createItemTask.Include.Select(item => item.ItemSpec).ToArray(); }