diff --git a/eng/Versions.props b/eng/Versions.props
index 3a4464aa77..37db296d24 100644
--- a/eng/Versions.props
+++ b/eng/Versions.props
@@ -27,6 +27,7 @@
8.0.0
9.0.11
+ 2.0.2
9.0.8
17.10.0-beta1.24272.1
3.1.23
diff --git a/src/Microsoft.Diagnostics.DebugServices.Implementation/CommandService.cs b/src/Microsoft.Diagnostics.DebugServices.Implementation/CommandService.cs
index 89b9a609bd..4fb46e9187 100644
--- a/src/Microsoft.Diagnostics.DebugServices.Implementation/CommandService.cs
+++ b/src/Microsoft.Diagnostics.DebugServices.Implementation/CommandService.cs
@@ -301,14 +301,9 @@ public CommandGroup(string commandPrompt = null)
internal bool Execute(IReadOnlyList commandLine, IServiceProvider services)
{
IConsoleService consoleService = services.GetService();
- CommandLineConfiguration configuration = new(_rootCommand)
- {
- Output = new ConsoleServiceWrapper(consoleService.Write),
- Error = new ConsoleServiceWrapper(consoleService.WriteError)
- };
-
- // Parse the command line and invoke the command
- ParseResult parseResult = configuration.Parse(commandLine);
+
+ // Parse the command line
+ ParseResult parseResult = _rootCommand.Parse(commandLine);
if (parseResult.Errors.Count > 0)
{
diff --git a/src/Tools/Common/Commands/ProcessStatus.cs b/src/Tools/Common/Commands/ProcessStatus.cs
index e5fa27cd97..f8c29ee139 100644
--- a/src/Tools/Common/Commands/ProcessStatus.cs
+++ b/src/Tools/Common/Commands/ProcessStatus.cs
@@ -4,6 +4,7 @@
using System;
using System.Collections.Generic;
using System.CommandLine;
+using System.CommandLine.Invocation;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
@@ -23,7 +24,7 @@ public class ProcessStatusCommandHandler
public static Command ProcessStatusCommand(string description)
{
Command statusCommand = new(name: "ps", description);
- statusCommand.SetAction((parseResult, ct) => Task.FromResult(ProcessStatus(parseResult.Configuration.Output, parseResult.Configuration.Error)));
+ statusCommand.SetAction((context, ct) => Task.FromResult(ProcessStatus(context.Console.Out, context.Console.Error)));
return statusCommand;
}
diff --git a/src/Tools/Common/ProcessTerminationHandler.cs b/src/Tools/Common/ProcessTerminationHandler.cs
index b5eb515f74..6d030b9ff8 100644
--- a/src/Tools/Common/ProcessTerminationHandler.cs
+++ b/src/Tools/Common/ProcessTerminationHandler.cs
@@ -31,7 +31,7 @@ internal static async Task InvokeAsync(ParseResult parseResult, string bloc
private static ProcessTerminationHandler ConfigureTerminationHandler(ParseResult parseResult, string blockedSignals)
{
// Use custom process terminate handler for the command line tool parse result.
- parseResult.Configuration.ProcessTerminationTimeout = null;
+ // Note: ProcessTerminationTimeout property was removed in System.CommandLine 2.0+
return new ProcessTerminationHandler(blockedSignals);
}
diff --git a/src/Tools/dotnet-dump/Program.cs b/src/Tools/dotnet-dump/Program.cs
index 6e5d18cca7..01ea1bed03 100644
--- a/src/Tools/dotnet-dump/Program.cs
+++ b/src/Tools/dotnet-dump/Program.cs
@@ -3,6 +3,7 @@
using System;
using System.CommandLine;
+using System.CommandLine.Invocation;
using System.IO;
using System.Threading.Tasks;
using Microsoft.Internal.Common;
@@ -31,16 +32,16 @@ private static Command CollectCommand()
ProcessIdOption, OutputOption, DiagnosticLoggingOption, CrashReportOption, TypeOption, ProcessNameOption, DiagnosticPortOption
};
- command.SetAction((parseResult) => new Dumper().Collect(
- stdOutput: parseResult.Configuration.Output,
- stdError: parseResult.Configuration.Error,
- processId: parseResult.GetValue(ProcessIdOption),
- output: parseResult.GetValue(OutputOption),
- diag: parseResult.GetValue(DiagnosticLoggingOption),
- crashreport: parseResult.GetValue(CrashReportOption),
- type: parseResult.GetValue(TypeOption),
- name: parseResult.GetValue(ProcessNameOption),
- diagnosticPort: parseResult.GetValue(DiagnosticPortOption)));
+ command.SetAction((context) => new Dumper().Collect(
+ stdOutput: context.Console.Out,
+ stdError: context.Console.Error,
+ processId: context.ParseResult.GetValue(ProcessIdOption),
+ output: context.ParseResult.GetValue(OutputOption),
+ diag: context.ParseResult.GetValue(DiagnosticLoggingOption),
+ crashreport: context.ParseResult.GetValue(CrashReportOption),
+ type: context.ParseResult.GetValue(TypeOption),
+ name: context.ParseResult.GetValue(ProcessNameOption),
+ diagnosticPort: context.ParseResult.GetValue(DiagnosticPortOption)));
return command;
}
diff --git a/src/Tools/dotnet-sos/Program.cs b/src/Tools/dotnet-sos/Program.cs
index 89a9e3ffc4..feadd51286 100644
--- a/src/Tools/dotnet-sos/Program.cs
+++ b/src/Tools/dotnet-sos/Program.cs
@@ -2,6 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.
using System.CommandLine;
+using System.CommandLine.Invocation;
using System.CommandLine.Parsing;
using System.IO;
using System.Runtime.InteropServices;
@@ -31,10 +32,10 @@ private static Command InstallCommand()
ArchitectureOption
};
- installCommand.SetAction(parseResult => Invoke(
- parseResult.Configuration.Output,
- parseResult.Configuration.Error,
- architecture: parseResult.GetValue(ArchitectureOption),
+ installCommand.SetAction(context => Invoke(
+ context.Console.Out,
+ context.Console.Error,
+ architecture: context.ParseResult.GetValue(ArchitectureOption),
install: true));
return installCommand;
@@ -52,9 +53,9 @@ private static Command UninstallCommand()
name: "uninstall",
description: "Uninstalls SOS and reverts any configuration changes to LLDB.");
- uninstallCommand.SetAction(parseResult => Invoke(
- parseResult.Configuration.Output,
- parseResult.Configuration.Error,
+ uninstallCommand.SetAction(context => Invoke(
+ context.Console.Out,
+ context.Console.Error,
architecture: null,
install: false));
diff --git a/src/Tools/dotnet-stack/ReportCommand.cs b/src/Tools/dotnet-stack/ReportCommand.cs
index 21e73f2d7e..cf853b6a91 100644
--- a/src/Tools/dotnet-stack/ReportCommand.cs
+++ b/src/Tools/dotnet-stack/ReportCommand.cs
@@ -4,6 +4,7 @@
using System;
using System.Collections.Generic;
using System.CommandLine;
+using System.CommandLine.Invocation;
using System.Diagnostics.Tracing;
using System.IO;
using System.Threading;
@@ -173,12 +174,12 @@ public static Command ReportCommand()
DurationOption
};
- reportCommand.SetAction((parseResult, ct) => Report(ct,
- stdOutput: parseResult.Configuration.Output,
- stdError: parseResult.Configuration.Error,
- processId: parseResult.GetValue(ProcessIdOption),
- name: parseResult.GetValue(NameOption),
- duration: parseResult.GetValue(DurationOption)));
+ reportCommand.SetAction((context, ct) => Report(ct,
+ stdOutput: context.Console.Out,
+ stdError: context.Console.Error,
+ processId: context.ParseResult.GetValue(ProcessIdOption),
+ name: context.ParseResult.GetValue(NameOption),
+ duration: context.ParseResult.GetValue(DurationOption)));
return reportCommand;
}
diff --git a/src/Tools/dotnet-stack/Symbolicate.cs b/src/Tools/dotnet-stack/Symbolicate.cs
index ce8b10e59b..2d2431c2d3 100644
--- a/src/Tools/dotnet-stack/Symbolicate.cs
+++ b/src/Tools/dotnet-stack/Symbolicate.cs
@@ -4,6 +4,7 @@
using System;
using System.Collections.Generic;
using System.CommandLine;
+using System.CommandLine.Invocation;
using System.IO;
using System.Linq;
using System.Reflection.Metadata;
@@ -305,13 +306,13 @@ public static Command SymbolicateCommand()
StandardOutOption
};
- symbolicateCommand.SetAction((parseResult, ct) => Task.FromResult(Symbolicate(
- stdOutput: parseResult.Configuration.Output,
- stdError: parseResult.Configuration.Error,
- inputPath: parseResult.GetValue(InputFileArgument),
- searchDir: parseResult.GetValue(SearchDirectoryOption),
- output: parseResult.GetValue(OutputFileOption),
- stdout: parseResult.GetValue(StandardOutOption))));
+ symbolicateCommand.SetAction((context, ct) => Task.FromResult(Symbolicate(
+ stdOutput: context.Console.Out,
+ stdError: context.Console.Error,
+ inputPath: context.ParseResult.GetValue(InputFileArgument),
+ searchDir: context.ParseResult.GetValue(SearchDirectoryOption),
+ output: context.ParseResult.GetValue(OutputFileOption),
+ stdout: context.ParseResult.GetValue(StandardOutOption))));
return symbolicateCommand;
}
diff --git a/src/Tools/dotnet-trace/CommandLine/Commands/CollectCommand.cs b/src/Tools/dotnet-trace/CommandLine/Commands/CollectCommand.cs
index c72f43686c..e14a039036 100644
--- a/src/Tools/dotnet-trace/CommandLine/Commands/CollectCommand.cs
+++ b/src/Tools/dotnet-trace/CommandLine/Commands/CollectCommand.cs
@@ -64,7 +64,7 @@ private void ConsoleWriteLine(string str = "")
/// A string, parsed as [payload_field_name]:[payload_field_value] pairs separated by commas, that will stop the trace upon hitting an event with a matching payload. Requires `--stopping-event-provider-name` and `--stopping-event-event-name` to be set.
/// Collect rundown events.
///
- internal async Task Collect(CancellationToken ct, CommandLineConfiguration cliConfig, int processId, FileInfo output, uint buffersize, string[] providers, string[] profile, TraceFileFormat format, TimeSpan duration, string clrevents, string clreventlevel, string name, string diagnosticPort, bool showchildio, bool resumeRuntime, string stoppingEventProviderName, string stoppingEventEventName, string stoppingEventPayloadFilter, bool? rundown, string dsrouter)
+ internal async Task Collect(CancellationToken ct, TextWriter stdOut, TextWriter stdError, int processId, FileInfo output, uint buffersize, string[] providers, string[] profile, TraceFileFormat format, TimeSpan duration, string clrevents, string clreventlevel, string name, string diagnosticPort, bool showchildio, bool resumeRuntime, string stoppingEventProviderName, string stoppingEventEventName, string stoppingEventPayloadFilter, bool? rundown, string dsrouter)
{
bool collectionStopped = false;
bool cancelOnEnter = true;
@@ -453,7 +453,7 @@ internal async Task Collect(CancellationToken ct, CommandLineConfiguration
if (format != TraceFileFormat.NetTrace)
{
string outputFilename = TraceFileFormatConverter.GetConvertedFilename(output.FullName, outputfile: null, format);
- TraceFileFormatConverter.ConvertToFormat(cliConfig.Output, cliConfig.Error, format, fileToConvert: output.FullName, outputFilename);
+ TraceFileFormatConverter.ConvertToFormat(stdOut, stdError, format, fileToConvert: output.FullName, outputFilename);
}
}
@@ -560,32 +560,33 @@ public static Command CollectCommand()
collectCommand.TreatUnmatchedTokensAsErrors = false; // see the logic in Program.Main that handles UnmatchedTokens
collectCommand.Description = "Collects a diagnostic trace from a currently running process or launch a child process and trace it. Append -- to the collect command to instruct the tool to run a command and trace it immediately. When tracing a child process, the exit code of dotnet-trace shall be that of the traced process unless the trace process encounters an error.";
- collectCommand.SetAction((parseResult, ct) =>
+ collectCommand.SetAction((context, ct) =>
{
CollectCommandHandler handler = new();
- string providersValue = parseResult.GetValue(CommonOptions.ProvidersOption) ?? string.Empty;
- string profileValue = parseResult.GetValue(CommonOptions.ProfileOption) ?? string.Empty;
+ string providersValue = context.ParseResult.GetValue(CommonOptions.ProvidersOption) ?? string.Empty;
+ string profileValue = context.ParseResult.GetValue(CommonOptions.ProfileOption) ?? string.Empty;
return handler.Collect(ct,
- cliConfig: parseResult.Configuration,
- processId: parseResult.GetValue(CommonOptions.ProcessIdOption),
- output: parseResult.GetValue(CommonOptions.OutputPathOption),
- buffersize: parseResult.GetValue(CircularBufferOption),
+ stdOut: context.Console.Out,
+ stdError: context.Console.Error,
+ processId: context.ParseResult.GetValue(CommonOptions.ProcessIdOption),
+ output: context.ParseResult.GetValue(CommonOptions.OutputPathOption),
+ buffersize: context.ParseResult.GetValue(CircularBufferOption),
providers: providersValue.Split(',', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries),
profile: profileValue.Split(',', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries),
- format: parseResult.GetValue(CommonOptions.FormatOption),
- duration: parseResult.GetValue(CommonOptions.DurationOption),
- clrevents: parseResult.GetValue(CommonOptions.CLREventsOption) ?? string.Empty,
- clreventlevel: parseResult.GetValue(CommonOptions.CLREventLevelOption) ?? string.Empty,
- name: parseResult.GetValue(CommonOptions.NameOption),
- diagnosticPort: parseResult.GetValue(DiagnosticPortOption) ?? string.Empty,
- showchildio: parseResult.GetValue(ShowChildIOOption),
- resumeRuntime: parseResult.GetValue(ResumeRuntimeOption),
- stoppingEventProviderName: parseResult.GetValue(StoppingEventProviderNameOption),
- stoppingEventEventName: parseResult.GetValue(StoppingEventEventNameOption),
- stoppingEventPayloadFilter: parseResult.GetValue(StoppingEventPayloadFilterOption),
- rundown: parseResult.GetValue(RundownOption),
- dsrouter: parseResult.GetValue(DSRouterOption));
+ format: context.ParseResult.GetValue(CommonOptions.FormatOption),
+ duration: context.ParseResult.GetValue(CommonOptions.DurationOption),
+ clrevents: context.ParseResult.GetValue(CommonOptions.CLREventsOption) ?? string.Empty,
+ clreventlevel: context.ParseResult.GetValue(CommonOptions.CLREventLevelOption) ?? string.Empty,
+ name: context.ParseResult.GetValue(CommonOptions.NameOption),
+ diagnosticPort: context.ParseResult.GetValue(DiagnosticPortOption) ?? string.Empty,
+ showchildio: context.ParseResult.GetValue(ShowChildIOOption),
+ resumeRuntime: context.ParseResult.GetValue(ResumeRuntimeOption),
+ stoppingEventProviderName: context.ParseResult.GetValue(StoppingEventProviderNameOption),
+ stoppingEventEventName: context.ParseResult.GetValue(StoppingEventEventNameOption),
+ stoppingEventPayloadFilter: context.ParseResult.GetValue(StoppingEventPayloadFilterOption),
+ rundown: context.ParseResult.GetValue(RundownOption),
+ dsrouter: context.ParseResult.GetValue(DSRouterOption));
});
return collectCommand;
diff --git a/src/Tools/dotnet-trace/CommandLine/Commands/ConvertCommand.cs b/src/Tools/dotnet-trace/CommandLine/Commands/ConvertCommand.cs
index 606c195901..fab34f1b32 100644
--- a/src/Tools/dotnet-trace/CommandLine/Commands/ConvertCommand.cs
+++ b/src/Tools/dotnet-trace/CommandLine/Commands/ConvertCommand.cs
@@ -4,6 +4,7 @@
using System;
using System.Collections.Generic;
using System.CommandLine;
+using System.CommandLine.Invocation;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
@@ -103,12 +104,12 @@ public static Command ConvertCommand()
OutputOption,
};
- convertCommand.SetAction((parseResult, ct) => Task.FromResult(ConvertFile(
- stdOut: parseResult.Configuration.Output,
- stdError: parseResult.Configuration.Error,
- inputFilename: parseResult.GetValue(InputFileArgument),
- format: parseResult.GetValue(CommonOptions.ConvertFormatOption),
- output: parseResult.GetValue(OutputOption
+ convertCommand.SetAction((context, ct) => Task.FromResult(ConvertFile(
+ stdOut: context.Console.Out,
+ stdError: context.Console.Error,
+ inputFilename: context.ParseResult.GetValue(InputFileArgument),
+ format: context.ParseResult.GetValue(CommonOptions.ConvertFormatOption),
+ output: context.ParseResult.GetValue(OutputOption
))));
return convertCommand;
diff --git a/src/tests/EventPipeStress/Common/Common.csproj b/src/tests/EventPipeStress/Common/Common.csproj
index 6147636936..14f3c4b2f9 100644
--- a/src/tests/EventPipeStress/Common/Common.csproj
+++ b/src/tests/EventPipeStress/Common/Common.csproj
@@ -5,7 +5,7 @@
-
+
\ No newline at end of file
diff --git a/src/tests/EventPipeStress/Orchestrator/Orchestrator.csproj b/src/tests/EventPipeStress/Orchestrator/Orchestrator.csproj
index 30aa2379a1..ceafecc19a 100644
--- a/src/tests/EventPipeStress/Orchestrator/Orchestrator.csproj
+++ b/src/tests/EventPipeStress/Orchestrator/Orchestrator.csproj
@@ -12,7 +12,7 @@
-
+
diff --git a/src/tests/EventPipeStress/Stress/Stress.csproj b/src/tests/EventPipeStress/Stress/Stress.csproj
index 3277f12440..1022b87c1d 100644
--- a/src/tests/EventPipeStress/Stress/Stress.csproj
+++ b/src/tests/EventPipeStress/Stress/Stress.csproj
@@ -7,7 +7,7 @@
-
+
diff --git a/src/tests/dotnet-trace/CollectCommandFunctionalTests.cs b/src/tests/dotnet-trace/CollectCommandFunctionalTests.cs
index 4a5dc38ab3..31c04e6b2c 100644
--- a/src/tests/dotnet-trace/CollectCommandFunctionalTests.cs
+++ b/src/tests/dotnet-trace/CollectCommandFunctionalTests.cs
@@ -21,7 +21,8 @@ public class CollectCommandFunctionalTests
public sealed record CollectArgs(
CancellationToken ct = default,
- CommandLineConfiguration cliConfig = null,
+ TextWriter stdOut = null,
+ TextWriter stdError = null,
int processId = -1,
uint buffersize = 1,
string[] providers = null,
@@ -91,7 +92,8 @@ private static async Task RunAsync(CollectArgs config, MockConsole console,
return await handler.Collect(
config.ct,
- config.cliConfig,
+ config.stdOut ?? Console.Out,
+ config.stdError ?? Console.Error,
config.ProcessId,
config.Output,
config.buffersize,