Created
March 6, 2025 14:53
-
-
Save TheAngryByrd/a2ec1a2cade0d4c3f4c53d5e42b362a2 to your computer and use it in GitHub Desktop.
Figure out why CoreCompile was run
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
// This is used to quickly diagnose why a rebuild happened in a large solution | |
// It reads a binlog file and finds all the CoreCompile targets that were triggered by a file being newer than the output file | |
// It then prints out the project and the messages that caused the rebuild | |
// to create a binlog you can refer to https://learn.microsoft.com/en-us/visualstudio/ide/msbuild-logs?view=vs-2022#provide-msbuild-binary-logs-for-investigation | |
// CLI: dotnet build -bl:mybinlog.binlog | |
// or in `.build/build.fs` add `BuildParameter.enableBinLog "mybinlog.binlog"` to the `build'` target. | |
// Use https://msbuildlog.com/ to diagnose further | |
#r "nuget: MSBuild.StructuredLogger" | |
open Microsoft.Build.Logging.StructuredLogger | |
/// Update your binlog path here | |
let binlog = "path/to/binlog.binlog" | |
let build = Serialization.Read binlog | |
let (|Message|_|) (b : BaseNode) = | |
match b with | |
| :? Message as m -> Some m | |
| _ -> None | |
let causations = | |
build | |
.FindChildrenRecursive<Target>(fun t -> | |
t.Name = "CoreCompile" | |
&& t.Children | |
|> Seq.exists(function Message m -> m.ToString().Contains "is newer than" | _ -> false) | |
) | |
causations | |
|> Seq.sortBy(fun t -> t.StartTime) | |
|> Seq.iter (fun t -> | |
printfn $"{t.Project} {t.Name}" | |
t.Children | |
|> Seq.iter(fun x -> printfn $" {x}" ) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment