Skip to content

Commit

Permalink
Bring back ProjectStarted.GlobalProperties (#6342)
Browse files Browse the repository at this point in the history
Some loggers depended on ProjectStartedEventArgs.GlobalProperties being not null and set. It will take a long time to move them to ProjectEvaluationFinished (needs to bump MSBuild dependency to 16.10).

For now log GlobalProperties in both places (ProjectStarted and ProjectEvaluationFinished). Hopefully the deduplication will save us from any significant increase in binlog size.

Fixes #6341
  • Loading branch information
KirillOsenkov committed Apr 13, 2021
1 parent 9bcc06c commit 8d57dfc
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 14 deletions.
9 changes: 5 additions & 4 deletions src/Build/BackEnd/Components/Logging/LoggingService.cs
Expand Up @@ -1170,10 +1170,11 @@ internal void InjectNonSerializedData(LogMessagePacket loggingPacket)
{
ErrorUtilities.VerifyThrow(_configCache.Value.HasConfiguration(projectStartedEventArgs.ProjectId), "Cannot find the project configuration while injecting non-serialized data from out-of-proc node.");
BuildRequestConfiguration buildRequestConfiguration = _configCache.Value[projectStartedEventArgs.ProjectId];
if (!IncludeEvaluationPropertiesAndItems)
{
s_projectStartedEventArgsGlobalProperties.Value.SetValue(projectStartedEventArgs, buildRequestConfiguration.GlobalProperties.ToDictionary(), null);
}

// Always log GlobalProperties on ProjectStarted for compatibility.
// There are loggers that depend on it being not-null and always set.
// See https://github.com/dotnet/msbuild/issues/6341 for details.
s_projectStartedEventArgsGlobalProperties.Value.SetValue(projectStartedEventArgs, buildRequestConfiguration.GlobalProperties.ToDictionary(), index: null);

s_projectStartedEventArgsToolsVersion.Value.SetValue(projectStartedEventArgs, buildRequestConfiguration.ToolsVersion, null);
}
Expand Down
Expand Up @@ -595,11 +595,9 @@ public BuildEventContext LogProjectStarted(BuildEventContext nodeBuildEventConte
ErrorUtilities.VerifyThrow(_configCache.Value.HasConfiguration(projectInstanceId), "Cannot find the project configuration while injecting non-serialized data from out-of-proc node.");
var buildRequestConfiguration = _configCache.Value[projectInstanceId];

IDictionary<string, string> globalProperties = null;
if (!IncludeEvaluationPropertiesAndItems)
{
globalProperties = buildRequestConfiguration.GlobalProperties.ToDictionary();
}
// Always log GlobalProperties on ProjectStarted
// See https://github.com/dotnet/msbuild/issues/6341 for details
IDictionary<string, string> globalProperties = buildRequestConfiguration.GlobalProperties.ToDictionary();

var buildEvent = new ProjectStartedEventArgs
(
Expand Down
6 changes: 1 addition & 5 deletions src/Build/Evaluation/Evaluator.cs
Expand Up @@ -785,11 +785,7 @@ private void Evaluate()

if (this._evaluationLoggingContext.LoggingService.IncludeEvaluationPropertiesAndItems)
{
if (_data.GlobalPropertiesDictionary.Count > 0)
{
globalProperties = _data.GlobalPropertiesDictionary;
}

globalProperties = _data.GlobalPropertiesDictionary;
properties = _data.Properties;
items = _data.Items;
}
Expand Down

0 comments on commit 8d57dfc

Please sign in to comment.