Created
September 29, 2020 19:31
-
-
Save jaredpar/7bcefddb6b3109eae454ce3789872c88 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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