Skip to content

Instantly share code, notes, and snippets.

@jaredpar
Created September 29, 2020 19:31
Show Gist options
  • Save jaredpar/7bcefddb6b3109eae454ce3789872c88 to your computer and use it in GitHub Desktop.
Save jaredpar/7bcefddb6b3109eae454ce3789872c88 to your computer and use it in GitHub Desktop.
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Microsoft.Build.Logging.StructuredLogger;
var build = BinaryLog.ReadBuild(@"p:\roslyn3\artifacts\log\Debug\Build.binlog");
var root = @"p:\roslyn3";
var sourceFileSet = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
build.VisitAllChildren<CscTask>(cscTask =>
{
Folder parameters = cscTask.FindChild((Folder c) => c.Name == Strings.Parameters);
if (parameters is null)
{
return;
}
foreach (var parameter in parameters.Children.OfType<Parameter>().Where(x => x.Name == "Sources"))
{
foreach (var child in parameter.Children)
{
switch (child)
{
case Item item:
AddFilePath(item.Text);
break;
default:
break;
}
}
}
void AddFilePath(string filePath)
{
if (!Path.IsPathRooted(filePath))
{
filePath = Path.Combine(root, filePath);
}
sourceFileSet.Add(filePath);
}
});
using var writer = new StreamWriter(@"p:\temp\files.txt");
foreach (var filePath in sourceFileSet)
{
writer.WriteLine(filePath);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment