Skip to content

Commit fe6a95a

Browse files
authored
Use terminal logger when building file-based apps (#49385)
1 parent 27ae645 commit fe6a95a

File tree

6 files changed

+12
-26
lines changed

6 files changed

+12
-26
lines changed

src/Cli/dotnet/Commands/Build/BuildCommand.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,7 @@ public static CommandBase FromParseResult(ParseResult parseResult, string msbuil
4545
{
4646
command = new VirtualProjectBuildingCommand(
4747
entryPointFileFullPath: Path.GetFullPath(arg),
48-
msbuildArgs: [.. forwardedOptions, .. binLogArgs],
49-
verbosity: parseResult.GetValue(CommonOptions.VerbosityOption),
50-
interactive: parseResult.GetValue(CommonOptions.InteractiveMsBuildForwardOption))
48+
msbuildArgs: [.. forwardedOptions, .. binLogArgs])
5149
{
5250
NoRestore = noRestore,
5351
NoCache = true,

src/Cli/dotnet/Commands/Publish/PublishCommand.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,7 @@ public static CommandBase FromParseResult(ParseResult parseResult, string? msbui
5959

6060
return new VirtualProjectBuildingCommand(
6161
entryPointFileFullPath: Path.GetFullPath(arg),
62-
msbuildArgs: msbuildArgs,
63-
verbosity: parseResult.GetValue(CommonOptions.VerbosityOption),
64-
interactive: parseResult.GetValue(CommonOptions.InteractiveMsBuildForwardOption))
62+
msbuildArgs: [.. msbuildArgs])
6563
{
6664
NoBuild = noBuild,
6765
NoRestore = noRestore,

src/Cli/dotnet/Commands/Restore/RestoreCommand.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,8 @@ public static CommandBase FromParseResult(ParseResult result, string? msbuildPat
3333
if (nonBinLogArgs is [{ } arg] && VirtualProjectBuildingCommand.IsValidEntryPointPath(arg))
3434
{
3535
return new VirtualProjectBuildingCommand(
36-
entryPointFileFullPath: Path.GetFullPath(arg),
37-
msbuildArgs: [.. forwardedOptions, ..binLogArgs],
38-
verbosity: result.GetValue(CommonOptions.VerbosityOption),
39-
interactive: result.GetValue(CommonOptions.InteractiveMsBuildForwardOption))
36+
entryPointFileFullPath: Path.GetFullPath(arg),
37+
msbuildArgs: [.. forwardedOptions, ..binLogArgs])
4038
{
4139
NoCache = true,
4240
NoBuild = true,

src/Cli/dotnet/Commands/Run/Api/RunApiCommand.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,7 @@ public override RunApiOutput Execute()
8686
{
8787
var buildCommand = new VirtualProjectBuildingCommand(
8888
entryPointFileFullPath: EntryPointFileFullPath,
89-
msbuildArgs: [],
90-
verbosity: VerbosityOptions.quiet,
91-
interactive: false)
89+
msbuildArgs: ["-verbosity:quiet"])
9290
{
9391
CustomArtifactsPath = ArtifactsPath,
9492
};

src/Cli/dotnet/Commands/Run/RunCommand.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -280,9 +280,7 @@ private VirtualProjectBuildingCommand CreateVirtualCommand()
280280

281281
return new(
282282
entryPointFileFullPath: EntryPointFileFullPath,
283-
msbuildArgs: RestoreArgs,
284-
verbosity: Verbosity,
285-
interactive: Interactive)
283+
msbuildArgs: RestoreArgs)
286284
{
287285
NoRestore = NoRestore,
288286
NoCache = NoCache,
@@ -394,7 +392,7 @@ static void InvokeRunArgumentsTarget(ProjectInstance project, string[] restoreAr
394392
}
395393
}
396394

397-
internal static ILogger MakeTerminalLogger(VerbosityOptions? verbosity)
395+
private static ILogger MakeTerminalLogger(VerbosityOptions? verbosity)
398396
{
399397
var msbuildVerbosity = ToLoggerVerbosity(verbosity);
400398

src/Cli/dotnet/Commands/Run/VirtualProjectBuildingCommand.cs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -112,23 +112,19 @@ Override targets which don't work with project files that are not present on dis
112112

113113
public VirtualProjectBuildingCommand(
114114
string entryPointFileFullPath,
115-
IReadOnlyList<string> msbuildArgs,
116-
VerbosityOptions? verbosity,
117-
bool interactive)
115+
string[] msbuildArgs)
118116
{
119117
Debug.Assert(Path.IsPathFullyQualified(entryPointFileFullPath));
120118

121119
EntryPointFileFullPath = entryPointFileFullPath;
122120
GlobalProperties = new(StringComparer.OrdinalIgnoreCase);
123121
CommonRunHelpers.AddUserPassedProperties(GlobalProperties, msbuildArgs);
124-
BinaryLoggerArgs = msbuildArgs;
125-
Verbosity = verbosity ?? RunCommand.GetDefaultVerbosity(interactive: interactive);
122+
LoggerArgs = msbuildArgs;
126123
}
127124

128125
public string EntryPointFileFullPath { get; }
129126
public Dictionary<string, string> GlobalProperties { get; }
130-
public IReadOnlyList<string> BinaryLoggerArgs { get; }
131-
public VerbosityOptions Verbosity { get; }
127+
public string[] LoggerArgs { get; }
132128
public string? CustomArtifactsPath { get; init; }
133129
public bool NoRestore { get; init; }
134130
public bool NoCache { get; init; }
@@ -138,8 +134,8 @@ public VirtualProjectBuildingCommand(
138134
public override int Execute()
139135
{
140136
Debug.Assert(!(NoRestore && NoBuild));
141-
var consoleLogger = RunCommand.MakeTerminalLogger(Verbosity);
142-
var binaryLogger = GetBinaryLogger(BinaryLoggerArgs);
137+
var consoleLogger = TerminalLogger.CreateTerminalOrConsoleLogger(LoggerArgs);
138+
var binaryLogger = GetBinaryLogger(LoggerArgs);
143139

144140
RunFileBuildCacheEntry? cacheEntry = null;
145141

0 commit comments

Comments
 (0)