Skip to content

Commit 2055530

Browse files
authored
Merge pull request #7 from dagood/getfiles-vs-15.5
Unblock official build on VS 15.5+
2 parents 1d18521 + b20907c commit 2055530

File tree

4 files changed

+27
-20
lines changed

4 files changed

+27
-20
lines changed

src/Microsoft.SourceIndexer.Tasks/SelectProjects.cs

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
using System;
1+
using System;
22
using System.Collections.Generic;
33
using System.IO;
44
using System.Linq;
5-
using System.Reflection;
65
using Microsoft.Build.Framework;
6+
using Microsoft.Build.Tasks;
77
using Microsoft.Build.Utilities;
88

99
namespace Microsoft.SourceIndexer.Tasks
@@ -30,25 +30,24 @@ public override bool Execute()
3030
}
3131
}
3232

33-
private static Type FileMatcher { get; } = Type.GetType("Microsoft.Build.Shared.FileMatcher, Microsoft.Build.Tasks.Core, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a");
34-
35-
private static Func<string, string, string[]> GetFiles { get; } =
36-
GetGetFilesFunction();
37-
38-
private static Func<string, string, string[]> GetGetFilesFunction()
33+
private string[] GetFiles(string localPath, string glob)
3934
{
40-
var func14 = FileMatcher.GetMethod("GetFiles", BindingFlags.NonPublic | BindingFlags.Static, null, new[] { typeof(string), typeof(string) }, new ParameterModifier[0]);
41-
if (func14 != null)
35+
var createItemTask = new CreateItem
4236
{
43-
return (Func<string, string, string[]>)func14.CreateDelegate(typeof(Func<string, string, string[]>));
44-
}
45-
var func15 = FileMatcher.GetMethod("GetFiles", BindingFlags.NonPublic | BindingFlags.Static, null, new[] { typeof(string), typeof(string), typeof(IEnumerable<string>) }, new ParameterModifier[0]);
46-
if (func15 != null)
37+
BuildEngine = BuildEngine,
38+
Include = new[]
39+
{
40+
new TaskItem(Path.Combine(localPath, glob))
41+
}
42+
};
43+
44+
if (!createItemTask.Execute())
4745
{
48-
var f = (Func<string, string, IEnumerable<string>, string[]>)func15.CreateDelegate(typeof(Func<string, string, IEnumerable<string>, string[]>));
49-
return (a, b) => f(a, b, Enumerable.Empty<string>());
46+
throw new Exception(
47+
$"Failed to create items with localPath '{localPath}', glob '{glob}'");
5048
}
51-
throw new MissingMethodException("Could not find FileMatcher.GetFiles");
49+
50+
return createItemTask.Include.Select(item => item.ItemSpec).ToArray();
5251
}
5352

5453

src/index/index.proj

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,16 @@
3333

3434
<Target Name="Clone" DependsOnTargets="PrepareOutput" Outputs="%(Repository.Identity)">
3535
<PropertyGroup>
36-
<CloneCommand>git clone %(Repository.Url).git --depth 1 -b %(Branch) --single-branch %(LocalPath)</CloneCommand>
36+
<CloneCommand>git clone %(Repository.Url).git -b %(Branch) --single-branch</CloneCommand>
37+
<CloneCommand Condition="'%(Repository.OldCommit)' == ''">$(CloneCommand) --depth 1</CloneCommand>
38+
<CloneCommand>$(CloneCommand) %(Repository.LocalPath)</CloneCommand>
39+
40+
<CheckoutCommand Condition="'%(Repository.OldCommit)' != ''">git -C %(Repository.LocalPath) checkout %(Repository.OldCommit)</CheckoutCommand>
41+
42+
<CloneExists Condition="Exists('%(Repository.LocalPath)')">true</CloneExists>
3743
</PropertyGroup>
38-
<Exec Condition="!Exists('%(Repository.LocalPath)')" Command="$(CloneCommand)" />
44+
<Exec Condition="'$(CloneExists)' != 'true'" Command="$(CloneCommand)" />
45+
<Exec Condition="'$(CloneExists)' != 'true' and '$(CheckoutCommand)' != ''" Command="$(CheckoutCommand)" />
3946
<Exec Command="git rev-parse HEAD 2>&amp;1" WorkingDirectory="%(Repository.LocalPath)" ConsoleToMSBuild="true">
4047
<Output TaskParameter="ConsoleOutput" PropertyName="CommitHash"/>
4148
</Exec>

src/index/repositories.props

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
<Repository Include="msbuild">
3535
<Url>https://github.com/Microsoft/msbuild</Url>
3636
<Branch>master</Branch>
37+
<OldCommit>91c86a746b312fce1aba31f8fb8540e949c11a01</OldCommit>
3738
<Projects>
3839
build/**/*.csproj;
3940
build/**/*.vbproj;

0 commit comments

Comments
 (0)