Skip to content
Merged
Show file tree
Hide file tree
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
33 changes: 16 additions & 17 deletions src/Microsoft.SourceIndexer.Tasks/SelectProjects.cs
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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<string, string, string[]> GetFiles { get; } =
GetGetFilesFunction();

private static Func<string, string, string[]> 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<string, string, string[]>)func14.CreateDelegate(typeof(Func<string, string, string[]>));
}
var func15 = FileMatcher.GetMethod("GetFiles", BindingFlags.NonPublic | BindingFlags.Static, null, new[] { typeof(string), typeof(string), typeof(IEnumerable<string>) }, new ParameterModifier[0]);
if (func15 != null)
BuildEngine = BuildEngine,
Include = new[]
{
new TaskItem(Path.Combine(localPath, glob))
}
};

if (!createItemTask.Execute())
{
var f = (Func<string, string, IEnumerable<string>, string[]>)func15.CreateDelegate(typeof(Func<string, string, IEnumerable<string>, string[]>));
return (a, b) => f(a, b, Enumerable.Empty<string>());
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();
}


Expand Down
11 changes: 9 additions & 2 deletions src/index/index.proj
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,16 @@

<Target Name="Clone" DependsOnTargets="PrepareOutput" Outputs="%(Repository.Identity)">
<PropertyGroup>
<CloneCommand>git clone %(Repository.Url).git --depth 1 -b %(Branch) --single-branch %(LocalPath)</CloneCommand>
<CloneCommand>git clone %(Repository.Url).git -b %(Branch) --single-branch</CloneCommand>
<CloneCommand Condition="'%(Repository.OldCommit)' == ''">$(CloneCommand) --depth 1</CloneCommand>
<CloneCommand>$(CloneCommand) %(Repository.LocalPath)</CloneCommand>

<CheckoutCommand Condition="'%(Repository.OldCommit)' != ''">git -C %(Repository.LocalPath) checkout %(Repository.OldCommit)</CheckoutCommand>

<CloneExists Condition="Exists('%(Repository.LocalPath)')">true</CloneExists>
</PropertyGroup>
<Exec Condition="!Exists('%(Repository.LocalPath)')" Command="$(CloneCommand)" />
<Exec Condition="'$(CloneExists)' != 'true'" Command="$(CloneCommand)" />
<Exec Condition="'$(CloneExists)' != 'true' and '$(CheckoutCommand)' != ''" Command="$(CheckoutCommand)" />
<Exec Command="git rev-parse HEAD 2>&amp;1" WorkingDirectory="%(Repository.LocalPath)" ConsoleToMSBuild="true">
<Output TaskParameter="ConsoleOutput" PropertyName="CommitHash"/>
</Exec>
Expand Down
1 change: 1 addition & 0 deletions src/index/repositories.props
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
<Repository Include="msbuild">
<Url>https://github.com/Microsoft/msbuild</Url>
<Branch>master</Branch>
<OldCommit>91c86a746b312fce1aba31f8fb8540e949c11a01</OldCommit>
<Projects>
build/**/*.csproj;
build/**/*.vbproj;
Expand Down