From 9bedd91c62bf6e547a71e84554b9cb920fdcb415 Mon Sep 17 00:00:00 2001 From: Kirill Osenkov Date: Wed, 5 Jan 2022 11:09:01 -0800 Subject: [PATCH] Embed EmbedInBinlog items added within targets So far we've only respected EmbedInBinlog items during ProjectEvaluationFinished (or ProjectStarted, wherever the eval items are logged). This simple change also respects EmbedInBinlog items added from ItemGroups inside Targets during target execution. We can now insert "printf" targets in any place in the build to embed arbitrary files in the binlog at the time that target runs. This could also allow embedding the same file more than once, if we first copy into a temp file with a timestamp or target name attached. This can allow capturing the state of files at various stages of the build. --- src/Build/Logging/BinaryLogger/BuildEventArgsWriter.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Build/Logging/BinaryLogger/BuildEventArgsWriter.cs b/src/Build/Logging/BinaryLogger/BuildEventArgsWriter.cs index 20583b991b0..c95b2dec850 100644 --- a/src/Build/Logging/BinaryLogger/BuildEventArgsWriter.cs +++ b/src/Build/Logging/BinaryLogger/BuildEventArgsWriter.cs @@ -516,6 +516,10 @@ private void Write(TaskParameterEventArgs e) Write((int)e.Kind); WriteDeduplicatedString(e.ItemType); WriteTaskItemList(e.Items, e.LogItemMetadata); + if (e.Kind == TaskParameterMessageKind.AddItem) + { + CheckForFilesToEmbed(e.ItemType, e.Items); + } } private void WriteBuildEventArgsFields(BuildEventArgs e, bool writeMessage = true, bool writeLineAndColumn = false)