Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use repository root for output path calculation when the output isn't a child of the working directory #9805

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
30 changes: 30 additions & 0 deletions src/MSBuild/TerminalLogger/EvaluationData.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

internal sealed class EvaluationData
{
/// <summary>
/// Captures data that comes from project evaluation, is assumed to not change through execution,
/// and is referenced for rendering purposes throughout the execution of the build.
/// </summary>
/// <param name="targetFramework"></param>
public EvaluationData(string? targetFramework)
{
TargetFramework = targetFramework;
}

/// <summary>
/// The target framework of the project or null if not multi-targeting.
/// </summary>
public string? TargetFramework { get; }

/// <summary>
/// This property is true when the project would prefer to have full paths in the logs and/or for processing tasks.
/// </summary>
/// <remarks>
/// There's an MSBuild property called GenerateFullPaths that would be a great knob to use for this, but the Common
/// Targets set it to true if not set, and setting it to false completely destroys the terminal logger output.
/// That's why this value is hardcoded to false for now, until we define a better mechanism.
/// </remarks>
public bool GenerateFullPaths { get; } = false;
}
21 changes: 15 additions & 6 deletions src/MSBuild/TerminalLogger/Project.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

#if NETFRAMEWORK
using Microsoft.IO;
#else
using System.IO;
#endif
using System;
using System.Collections.Generic;
using System.Diagnostics;
Expand All @@ -10,16 +15,15 @@ namespace Microsoft.Build.Logging.TerminalLogger;
/// <summary>
/// Represents a project being built.
/// </summary>
[DebuggerDisplay("{OutputPath}({TargetFramework})")]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: You've removed the TargetFramework property.

internal sealed class Project
{
/// <summary>
/// Initialized a new <see cref="Project"/> with the given <paramref name="targetFramework"/>.
/// </summary>
/// <param name="targetFramework">The target framework of the project or null if not multi-targeting.</param>
public Project(string? targetFramework, StopwatchAbstraction? stopwatch)
public Project(StopwatchAbstraction? stopwatch)
{
TargetFramework = targetFramework;

if (stopwatch is not null)
{
stopwatch.Start();
Expand All @@ -39,12 +43,12 @@ public Project(string? targetFramework, StopwatchAbstraction? stopwatch)
/// <summary>
/// Full path to the primary output of the project, if known.
/// </summary>
public ReadOnlyMemory<char>? OutputPath { get; set; }
public FileInfo? OutputPath { get; set; }

/// <summary>
/// The target framework of the project or null if not multi-targeting.
/// Full path to the 'root' of this project's source control repository, if known.
/// </summary>
public string? TargetFramework { get; }
public DirectoryInfo? SourceRoot { get; set; }

/// <summary>
/// True when the project has run target with name "_TestRunStart" defined in <see cref="TerminalLogger._testStartTarget"/>.
Expand All @@ -56,6 +60,11 @@ public Project(string? targetFramework, StopwatchAbstraction? stopwatch)
/// </summary>
public bool IsCachePluginProject { get; set; }

/// <summary>
/// This property is true when the project would prefer to have full paths in the logs and/or for processing tasks.
/// </summary>
public bool GenerateFullPaths { get; set; }

/// <summary>
/// A lazily initialized list of build messages/warnings/errors raised during the build.
/// </summary>
Expand Down
Loading
Loading