Skip to content

Commit

Permalink
Notify MSBuild TerminalLogger of project cache plugin starting
Browse files Browse the repository at this point in the history
  • Loading branch information
mruxmohan4 committed Apr 19, 2024
1 parent 72d49c3 commit 69635ee
Show file tree
Hide file tree
Showing 16 changed files with 132 additions and 6 deletions.
7 changes: 7 additions & 0 deletions src/MSBuild/Resources/Strings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -1184,6 +1184,13 @@
<data name="PossiblyOmittedMaxCPUSwitch" xml:space="preserve">
<value>Building the projects in this solution one at a time. To enable parallel build, please add the "-m" switch.</value>
</data>
<data name="CachePluginProjectFinished_OutputPath" xml:space="preserve">
<value> -> {0}</value>
<comment>
Info about project output - when known. Printed after ProjectFinished_NoTF or ProjectFinished_WithTF.
{0}: VT100 coded hyperlink to project output directory
</comment>
</data>
<data name="ProjectSchemaErrorHalt" xml:space="preserve">
<value>MSBUILD : MSB1045: Stopping because of syntax errors in project file.</value>
<comment>{StrBegin="MSBUILD : MSB1045: "}</comment>
Expand Down
8 changes: 8 additions & 0 deletions src/MSBuild/Resources/xlf/Strings.cs.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions src/MSBuild/Resources/xlf/Strings.de.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions src/MSBuild/Resources/xlf/Strings.es.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions src/MSBuild/Resources/xlf/Strings.fr.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions src/MSBuild/Resources/xlf/Strings.it.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions src/MSBuild/Resources/xlf/Strings.ja.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions src/MSBuild/Resources/xlf/Strings.ko.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions src/MSBuild/Resources/xlf/Strings.pl.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions src/MSBuild/Resources/xlf/Strings.pt-BR.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions src/MSBuild/Resources/xlf/Strings.ru.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions src/MSBuild/Resources/xlf/Strings.tr.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions src/MSBuild/Resources/xlf/Strings.zh-Hans.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions src/MSBuild/Resources/xlf/Strings.zh-Hant.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/MSBuild/TerminalLogger/Project.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ public Project(string? targetFramework, StopwatchAbstraction? stopwatch)
/// </summary>
public bool IsTestProject { get; set; }

/// <summary>
/// True when the project has run target with name "_CachePluginRunStart" defined in <see cref="TerminalLogger._cachePluginStartTarget"/>.
/// </summary>
public bool IsCachePluginProject { get; set; }

/// <summary>
/// A lazily initialized list of build messages/warnings/errors raised during the build.
/// </summary>
Expand Down
22 changes: 16 additions & 6 deletions src/MSBuild/TerminalLogger/TerminalLogger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,11 @@ public ProjectContext(BuildEventContext context)
/// </summary>
private DateTime? _testEndTime;

/// <summary>
/// Name of target that identifies the project cache plugin run has just started.
/// </summary>
private static string _cachePluginStartTarget = "_CachePluginRunStart";

/// <summary>
/// Whether to show TaskCommandLineEventArgs high-priority messages.
/// </summary>
Expand Down Expand Up @@ -630,7 +635,8 @@ private void ProjectFinished(object sender, ProjectFinishedEventArgs e)
}
}

Terminal.WriteLine(ResourceUtilities.FormatResourceStringIgnoreCodeAndKeyword("ProjectFinished_OutputPath",
string resourceName = project.IsCachePluginProject ? "CachePluginProjectFinished_OutputPath" : "ProjectFinished_OutputPath";
Terminal.WriteLine(ResourceUtilities.FormatResourceStringIgnoreCodeAndKeyword(resourceName,
$"{AnsiCodes.LinkPrefix}{urlString}{AnsiCodes.LinkInfix}{outputPathSpan.ToString()}{AnsiCodes.LinkSuffix}"));
}
else
Expand Down Expand Up @@ -673,12 +679,16 @@ private void TargetStarted(object sender, TargetStartedEventArgs e)

string projectFile = Path.GetFileNameWithoutExtension(e.ProjectFile);

string targetName = e.TargetName;
if (targetName == _cachePluginStartTarget)
{
project.IsCachePluginProject = true;
}

var isTestTarget = e.TargetName == _testStartTarget;

var targetName = isTestTarget ? "Testing" : e.TargetName;
if (isTestTarget)
if (targetName == _testStartTarget)
{
targetName = "Testing";

// Use the minimal start time, so if we run tests in parallel, we can calculate duration
// as this start time, minus time when tests finished.
_testStartTime = _testStartTime == null
Expand Down Expand Up @@ -931,7 +941,7 @@ private void ErrorRaised(object sender, BuildErrorEventArgs e)
}
}

#endregion
#endregion

#region Refresher thread implementation

Expand Down

0 comments on commit 69635ee

Please sign in to comment.