From 44fd77605e4fd2e048fd919b87015a4c40d8992e Mon Sep 17 00:00:00 2001 From: "dotnet-maestro[bot]" <42748379+dotnet-maestro[bot]@users.noreply.github.com> Date: Fri, 1 Aug 2025 03:19:33 +0000 Subject: [PATCH 1/4] [main] Update dependencies from microsoft/clrmd (#5537) [main] Update dependencies from microsoft/clrmd --- eng/Version.Details.xml | 8 ++++---- eng/Versions.props | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/eng/Version.Details.xml b/eng/Version.Details.xml index 6acf25d322..05d18eeebb 100644 --- a/eng/Version.Details.xml +++ b/eng/Version.Details.xml @@ -1,13 +1,13 @@ - + https://github.com/microsoft/clrmd - 02791bfe45e47611bebc437caaf659319b5bd893 + f11663fc2e71ddd0869deb528047f0f476a0e346 - + https://github.com/microsoft/clrmd - 02791bfe45e47611bebc437caaf659319b5bd893 + f11663fc2e71ddd0869deb528047f0f476a0e346 https://github.com/dotnet/android diff --git a/eng/Versions.props b/eng/Versions.props index b9e1382871..0c87ffac26 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -48,7 +48,7 @@ 8.0.0 6.0.0 - 4.0.0-beta.25380.1 + 4.0.0-beta.25381.2 17.10.0-beta1.24272.1 3.1.23 6.0.0 From 745ee213fbae0dca180670fec363ad1b48c193a9 Mon Sep 17 00:00:00 2001 From: Juan Hoyos <19413848+hoyosjs@users.noreply.github.com> Date: Mon, 4 Aug 2025 23:22:34 -0700 Subject: [PATCH 2/4] Add missing dependency node (#5539) --- eng/Version.Details.xml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/eng/Version.Details.xml b/eng/Version.Details.xml index 05d18eeebb..c091617ddb 100644 --- a/eng/Version.Details.xml +++ b/eng/Version.Details.xml @@ -9,6 +9,10 @@ https://github.com/microsoft/clrmd f11663fc2e71ddd0869deb528047f0f476a0e346 + + https://github.com/dotnet/command-line-api + e9b0511d7f1128e2bc3be7a658a2a4ea977e602d + https://github.com/dotnet/android bf304cf475308547a2a1a342bb9f2e6825cc33cd From cddfe4f749082622c84beffa2835698e1ee7ba48 Mon Sep 17 00:00:00 2001 From: Jonathan Peppers Date: Tue, 5 Aug 2025 02:24:45 -0500 Subject: [PATCH 3/4] [dsrouter] improve log message when launched as a subprocess (#5536) `dotnet-trace collect --dsrouter android` logs an unnecessary message currently: Run diagnotic tool connecting application on android device through dotnet-dsrouter pid=38004: dotnet-trace collect -p 38004 `dotnet-trace` is launching and controlling `dotnet-dsrouter`, and so you would not need to run `dotnet-trace collect -p 38004`. To solve this: * Pass `--parentprocess pid:name` when launching `dotnet-dsrouter` from `dotnet-trace` * `dotnet-dsrouter` checks `--parentprocess` switch to tell if it is running as a subprocess * Only log this message when *not* a subprocess --- src/Tools/Common/DsRouterProcessLauncher.cs | 4 ++- .../DiagnosticsServerRouterCommands.cs | 25 +++++++++------- src/Tools/dotnet-dsrouter/Program.cs | 30 ++++++++++++++----- 3 files changed, 39 insertions(+), 20 deletions(-) diff --git a/src/Tools/Common/DsRouterProcessLauncher.cs b/src/Tools/Common/DsRouterProcessLauncher.cs index 626c333227..e4c93efa30 100644 --- a/src/Tools/Common/DsRouterProcessLauncher.cs +++ b/src/Tools/Common/DsRouterProcessLauncher.cs @@ -127,8 +127,10 @@ public int Start(string dsrouterCommand, CancellationToken ct) dotnetDsrouterTool = Path.Combine(toolsRoot, dotnetDsrouterTool); } + using Process currentProcess = Process.GetCurrentProcess(); + // Block SIGINT and SIGQUIT in child process. - dsrouterCommand += " --block-signals SIGINT;SIGQUIT"; + dsrouterCommand += $" --block-signals SIGINT;SIGQUIT --parentprocess \"{currentProcess.Id}:{currentProcess.ProcessName}\""; _childProc = new Process(); diff --git a/src/Tools/dotnet-dsrouter/DiagnosticsServerRouterCommands.cs b/src/Tools/dotnet-dsrouter/DiagnosticsServerRouterCommands.cs index f7f64a122f..0f657df026 100644 --- a/src/Tools/dotnet-dsrouter/DiagnosticsServerRouterCommands.cs +++ b/src/Tools/dotnet-dsrouter/DiagnosticsServerRouterCommands.cs @@ -357,41 +357,41 @@ public async Task RunIpcClientWebSocketServerRouter(CancellationToken token } } - public async Task RunIpcServerIOSSimulatorRouter(CancellationToken token, int runtimeTimeout, string verbose, bool info) + public async Task RunIpcServerIOSSimulatorRouter(CancellationToken token, int runtimeTimeout, string verbose, bool info, string parentProcess) { if (info || ParseLogLevel(verbose) <= LogLevel.Information) { - logRouterUsageInfo("ios simulator", "127.0.0.1:9000", true); + logRouterUsageInfo("ios simulator", "127.0.0.1:9000", true, parentProcess); } return await RunIpcServerTcpClientRouter(token, "", "127.0.0.1:9000", runtimeTimeout, verbose, "").ConfigureAwait(false); } - public async Task RunIpcServerIOSRouter(CancellationToken token, int runtimeTimeout, string verbose, bool info) + public async Task RunIpcServerIOSRouter(CancellationToken token, int runtimeTimeout, string verbose, bool info, string parentProcess) { if (info || ParseLogLevel(verbose) <= LogLevel.Information) { - logRouterUsageInfo("ios device", "127.0.0.1:9000", true); + logRouterUsageInfo("ios device", "127.0.0.1:9000", true, parentProcess); } return await RunIpcServerTcpClientRouter(token, "", "127.0.0.1:9000", runtimeTimeout, verbose, "iOS").ConfigureAwait(false); } - public async Task RunIpcServerAndroidEmulatorRouter(CancellationToken token, int runtimeTimeout, string verbose, bool info) + public async Task RunIpcServerAndroidEmulatorRouter(CancellationToken token, int runtimeTimeout, string verbose, bool info, string parentProcess) { if (info || ParseLogLevel(verbose) <= LogLevel.Information) { - logRouterUsageInfo("android emulator", "10.0.2.2:9000", false); + logRouterUsageInfo("android emulator", "10.0.2.2:9000", false, parentProcess); } return await RunIpcServerTcpServerRouter(token, "", "127.0.0.1:9000", runtimeTimeout, verbose, "").ConfigureAwait(false); } - public async Task RunIpcServerAndroidRouter(CancellationToken token, int runtimeTimeout, string verbose, bool info) + public async Task RunIpcServerAndroidRouter(CancellationToken token, int runtimeTimeout, string verbose, bool info, string parentProcess) { if (info || ParseLogLevel(verbose) <= LogLevel.Information) { - logRouterUsageInfo("android device", "127.0.0.1:9000", false); + logRouterUsageInfo("android device", "127.0.0.1:9000", false, parentProcess); } return await RunIpcServerTcpServerRouter(token, "", "127.0.0.1:9001", runtimeTimeout, verbose, "Android").ConfigureAwait(false); @@ -501,7 +501,7 @@ private static LogLevel ParseLogLevel(string verbose) return logLevel; } - private static void logRouterUsageInfo(string deviceName, string deviceTcpIpAddress, bool deviceListenMode) + private static void logRouterUsageInfo(string deviceName, string deviceTcpIpAddress, bool deviceListenMode, string parentProcess) { StringBuilder message = new(); @@ -514,8 +514,11 @@ private static void logRouterUsageInfo(string deviceName, string deviceTcpIpAddr message.AppendLine($"DOTNET_DiagnosticPorts={deviceTcpIpAddress},nosuspend,{listenMode}"); message.AppendLine("[Startup Tracing]"); message.AppendLine($"DOTNET_DiagnosticPorts={deviceTcpIpAddress},suspend,{listenMode}"); - message.AppendLine($"Run diagnotic tool connecting application on {deviceName} through dotnet-dsrouter pid={pid}:"); - message.AppendLine($"dotnet-trace collect -p {pid}"); + if (string.IsNullOrEmpty(parentProcess)) + { + message.AppendLine($"Run diagnotic tool connecting application on {deviceName} through dotnet-dsrouter pid={pid}:"); + message.AppendLine($"dotnet-trace collect -p {pid}"); + } message.AppendLine($"See https://learn.microsoft.com/en-us/dotnet/core/diagnostics/dotnet-dsrouter for additional details and examples."); ConsoleColor currentColor = Console.ForegroundColor; diff --git a/src/Tools/dotnet-dsrouter/Program.cs b/src/Tools/dotnet-dsrouter/Program.cs index 5449a9dead..bfd3deecfd 100644 --- a/src/Tools/dotnet-dsrouter/Program.cs +++ b/src/Tools/dotnet-dsrouter/Program.cs @@ -156,14 +156,15 @@ private static Command IOSSimulatorRouterCommand() "Router is configured using an IPC server (connecting to by diagnostic tools) " + "and a TCP/IP server (accepting runtime TCP client).") { - RuntimeTimeoutOption, VerboseOption, InfoOption, BlockedSignalsOption + RuntimeTimeoutOption, VerboseOption, InfoOption, BlockedSignalsOption, ParentProcessOption }; command.SetAction((parseResult, ct) => new DiagnosticsServerRouterCommands().RunIpcServerIOSSimulatorRouter( ct, runtimeTimeout: parseResult.GetValue(RuntimeTimeoutOption), verbose: parseResult.GetValue(VerboseOption), - info: parseResult.GetValue(InfoOption) + info: parseResult.GetValue(InfoOption), + parentProcess: parseResult.GetValue(ParentProcessOption) )); return command; @@ -177,14 +178,15 @@ private static Command IOSRouterCommand() "Router is configured using an IPC server (connecting to by diagnostic tools) " + "and a TCP/IP client (connecting runtime TCP server over usbmux).") { - RuntimeTimeoutOption, VerboseOption, InfoOption, BlockedSignalsOption + RuntimeTimeoutOption, VerboseOption, InfoOption, BlockedSignalsOption, ParentProcessOption }; command.SetAction((parseResult, ct) => new DiagnosticsServerRouterCommands().RunIpcServerIOSRouter( ct, runtimeTimeout: parseResult.GetValue(RuntimeTimeoutOption), verbose: parseResult.GetValue(VerboseOption), - info: parseResult.GetValue(InfoOption) + info: parseResult.GetValue(InfoOption), + parentProcess: parseResult.GetValue(ParentProcessOption) )); return command; @@ -198,14 +200,16 @@ private static Command AndroidEmulatorRouterCommand() "Router is configured using an IPC server (connecting to by diagnostic tools) " + "and a TCP/IP server (accepting runtime TCP client).") { - RuntimeTimeoutOption, VerboseOption, InfoOption, BlockedSignalsOption + RuntimeTimeoutOption, VerboseOption, InfoOption, BlockedSignalsOption, ParentProcessOption }; command.SetAction((parseResult, ct) => new DiagnosticsServerRouterCommands().RunIpcServerAndroidEmulatorRouter( ct, runtimeTimeout: parseResult.GetValue(RuntimeTimeoutOption), verbose: parseResult.GetValue(VerboseOption), - info: parseResult.GetValue(InfoOption))); + info: parseResult.GetValue(InfoOption), + parentProcess: parseResult.GetValue(ParentProcessOption) + )); return command; } @@ -218,14 +222,16 @@ private static Command AndroidRouterCommand() "Router is configured using an IPC server (connecting to by diagnostic tools) " + "and a TCP/IP server (accepting runtime TCP client).") { - RuntimeTimeoutOption, VerboseOption, InfoOption, BlockedSignalsOption + RuntimeTimeoutOption, VerboseOption, InfoOption, BlockedSignalsOption, ParentProcessOption }; command.SetAction((parseResult, ct) => new DiagnosticsServerRouterCommands().RunIpcServerAndroidRouter( ct, runtimeTimeout: parseResult.GetValue(RuntimeTimeoutOption), verbose: parseResult.GetValue(VerboseOption), - info: parseResult.GetValue(InfoOption))); + info: parseResult.GetValue(InfoOption), + parentProcess: parseResult.GetValue(ParentProcessOption) + )); return command; } @@ -304,6 +310,14 @@ private static Command AndroidRouterCommand() Description = "Print info on how to use current dotnet-dsrouter instance with application and diagnostic tooling." }; + private static readonly Option ParentProcessOption = + new("--parentprocess") + { + Description = "If dsrouter was launched from dotnet-trace or another .NET diagnostic tool, contains the parent process ID and name: --parentprocess pid:name", + DefaultValueFactory = _ => "", + Hidden = true + }; + private static Task Main(string[] args) { RootCommand rootCommand = new() From 8f85a72851b791ffe4c88d46e8def6facf2a68e7 Mon Sep 17 00:00:00 2001 From: Jonathan Peppers Date: Thu, 31 Jul 2025 13:11:36 -0500 Subject: [PATCH 4/4] [dsrouter] improved instructions/log messages Context: https://github.com/dotnet/android/pull/10351 Context: https://github.com/dotnet/macios/pull/23429 We are adding new MSBuild properties to simplify setting `$DOTNET_DiagnosticPorts` on mobile: * `$(DiagnosticAddress)` * `$(DiagnosticPort)` * `$(DiagnosticSuspend)` * `$(DiagnosticListenMode)` * `$(DiagnosticConfiguration)` if you want to specify the full value yourself, escape `,` with `%2c`, etc. We will ship these properties in future releases of .NET 9 and 10. To improve `dsrouter` the current log message: Start an application on android device with ONE of the following environment variables set: [Default Tracing] DOTNET_DiagnosticPorts=127.0.0.1:9000,nosuspend,connect [Startup Tracing] DOTNET_DiagnosticPorts=127.0.0.1:9000,suspend,connect Will change to: Build and run an Android application such as: [Default Tracing] dotnet build -t:Run -c Release -p:DiagnosticAddress=127.0.0.1 -p:DiagnosticPort=9000 -p:DiagnosticSuspend=false -p:DiagnosticListenMode=connect [Startup Tracing] dotnet build -t:Run -c Release -p:DiagnosticAddress=127.0.0.1 -p:DiagnosticPort=9000 -p:DiagnosticSuspend=true -p:DiagnosticListenMode=connect Note that `dotnet run` *does work*, but it doesn't show good progress on the build & deploy steps as compared to `dotnet build -t:Run` and MSBuild's terminal logger. It can take several seconds to run a `Release` build. I think it's better to recommend `-t:Run` until we improve `dotnet run`. --- .../DiagnosticsServerRouterCommands.cs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Tools/dotnet-dsrouter/DiagnosticsServerRouterCommands.cs b/src/Tools/dotnet-dsrouter/DiagnosticsServerRouterCommands.cs index 0f657df026..bc0b0a3473 100644 --- a/src/Tools/dotnet-dsrouter/DiagnosticsServerRouterCommands.cs +++ b/src/Tools/dotnet-dsrouter/DiagnosticsServerRouterCommands.cs @@ -361,7 +361,7 @@ public async Task RunIpcServerIOSSimulatorRouter(CancellationToken token, i { if (info || ParseLogLevel(verbose) <= LogLevel.Information) { - logRouterUsageInfo("ios simulator", "127.0.0.1:9000", true, parentProcess); + logRouterUsageInfo("ios simulator", "127.0.0.1", "9000", true, parentProcess); } return await RunIpcServerTcpClientRouter(token, "", "127.0.0.1:9000", runtimeTimeout, verbose, "").ConfigureAwait(false); @@ -371,7 +371,7 @@ public async Task RunIpcServerIOSRouter(CancellationToken token, int runtim { if (info || ParseLogLevel(verbose) <= LogLevel.Information) { - logRouterUsageInfo("ios device", "127.0.0.1:9000", true, parentProcess); + logRouterUsageInfo("ios device", "127.0.0.1", "9000", true, parentProcess); } return await RunIpcServerTcpClientRouter(token, "", "127.0.0.1:9000", runtimeTimeout, verbose, "iOS").ConfigureAwait(false); @@ -381,7 +381,7 @@ public async Task RunIpcServerAndroidEmulatorRouter(CancellationToken token { if (info || ParseLogLevel(verbose) <= LogLevel.Information) { - logRouterUsageInfo("android emulator", "10.0.2.2:9000", false, parentProcess); + logRouterUsageInfo("android emulator", "10.0.2.2", "9000", false, parentProcess); } return await RunIpcServerTcpServerRouter(token, "", "127.0.0.1:9000", runtimeTimeout, verbose, "").ConfigureAwait(false); @@ -391,7 +391,7 @@ public async Task RunIpcServerAndroidRouter(CancellationToken token, int ru { if (info || ParseLogLevel(verbose) <= LogLevel.Information) { - logRouterUsageInfo("android device", "127.0.0.1:9000", false, parentProcess); + logRouterUsageInfo("android device", "127.0.0.1", "9000", false, parentProcess); } return await RunIpcServerTcpServerRouter(token, "", "127.0.0.1:9001", runtimeTimeout, verbose, "Android").ConfigureAwait(false); @@ -501,7 +501,7 @@ private static LogLevel ParseLogLevel(string verbose) return logLevel; } - private static void logRouterUsageInfo(string deviceName, string deviceTcpIpAddress, bool deviceListenMode, string parentProcess) + private static void logRouterUsageInfo(string deviceName, string deviceTcpIpAddress, string deviceTcpIpPort, bool deviceListenMode, string parentProcess) { StringBuilder message = new(); @@ -509,11 +509,11 @@ private static void logRouterUsageInfo(string deviceName, string deviceTcpIpAddr int pid = Process.GetCurrentProcess().Id; message.AppendLine($"How to connect current dotnet-dsrouter pid={pid} with {deviceName} and diagnostics tooling."); - message.AppendLine($"Start an application on {deviceName} with ONE of the following environment variables set:"); + message.AppendLine($"Build and run your application on {deviceName} such as:"); message.AppendLine("[Default Tracing]"); - message.AppendLine($"DOTNET_DiagnosticPorts={deviceTcpIpAddress},nosuspend,{listenMode}"); + message.AppendLine($"dotnet build -t:Run -c Release -p:DiagnosticAddress={deviceTcpIpAddress} -p:DiagnosticPort={deviceTcpIpPort} -p:DiagnosticSuspend=false -p:DiagnosticListenMode={listenMode}"); message.AppendLine("[Startup Tracing]"); - message.AppendLine($"DOTNET_DiagnosticPorts={deviceTcpIpAddress},suspend,{listenMode}"); + message.AppendLine($"dotnet build -t:Run -c Release -p:DiagnosticAddress={deviceTcpIpAddress} -p:DiagnosticPort={deviceTcpIpPort} -p:DiagnosticSuspend=true -p:DiagnosticListenMode={listenMode}"); if (string.IsNullOrEmpty(parentProcess)) { message.AppendLine($"Run diagnotic tool connecting application on {deviceName} through dotnet-dsrouter pid={pid}:");