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
1 change: 1 addition & 0 deletions src/StructuredLogViewer/Entrypoint.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Diagnostics;
using System.Windows;
using System.Windows.Threading;
using Microsoft.Build.Logging.StructuredLogger;
Expand Down
9 changes: 8 additions & 1 deletion src/StructuredLogger/BinaryLogger/BuildEventArgsWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,14 @@ private void Write(BuildStartedEventArgs e)
{
Write(BinaryLogRecordKind.BuildStarted);
WriteBuildEventArgsFields(e);
Write(e.BuildEnvironment);
if (!string.IsNullOrEmpty(Environment.GetEnvironmentVariable("MSBUILDLOGALLENVIRONMENTVARIABLES")))
{
Write(e.BuildEnvironment);
}
else
{
Write(0);
}
}

private void Write(BuildFinishedEventArgs e)
Expand Down
14 changes: 12 additions & 2 deletions src/StructuredLogger/Construction/Construction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,18 @@ public void BuildStarted(object sender, BuildStartedEventArgs args)
lock (syncLock)
{
Build.StartTime = args.Timestamp;
var properties = Build.GetOrCreateNodeWithName<Folder>(Intern(Strings.Environment));
AddProperties(properties, args.BuildEnvironment);
if (args.BuildEnvironment?.Count > 0)
{
var properties = Build.GetOrCreateNodeWithName<Folder>(Intern(Strings.Environment));
AddProperties(properties, args.BuildEnvironment);
}
else
{
Build.AddChild(new Note
{
Text = Intern(Strings.NoEnvironment)
});
}

// realize the evaluation folder now so it is ordered before the main solution node
_ = EvaluationFolder;
Expand Down
6 changes: 5 additions & 1 deletion src/StructuredLogger/Construction/MessageProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,11 @@ public void AddMessage(LazyFormattedBuildEventArgs args, string message)
}
}

if (nodeToAdd == null)
if (args is EnvironmentVariableReadEventArgs envArgs)
{
nodeToAdd = new Property { Name = Intern(envArgs.EnvironmentVariableName), Value = Intern(message) };
}
else if (nodeToAdd == null)
{
message = Intern(message);
nodeToAdd = new Message
Expand Down
1 change: 1 addition & 0 deletions src/StructuredLogger/Strings/Strings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,7 @@ public static Match IsFoundConflicts(string text)

public static string Evaluation => "Evaluation";
public static string Environment => "Environment";
public static string NoEnvironment => "Define a value for MSBUILDLOGALLENVIRONMENTVARIABLES to log all environment variables. Only those used in evaluating properties are currently logged.";
public static string Imports => "Imports";
public static string DetailedSummary => "Detailed summary";
public static string Parameters => "Parameters";
Expand Down