KEMBAR78
[dsrouter] improved instructions/log messages by jonathanpeppers · Pull Request #5535 · dotnet/diagnostics · GitHub
Skip to content

Conversation

@jonathanpeppers
Copy link
Member

Context: dotnet/android#10351
Context: dotnet/macios#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.

@jonathanpeppers
Copy link
Member Author

Going to keep this in draft until we know the release dates of everything.

Context: dotnet/android#10351
Context: dotnet/macios#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`.
@jonathanpeppers jonathanpeppers force-pushed the dev/peppers/dsrouter-instructions branch from 56b0c2c to 8f85a72 Compare August 6, 2025 15:22
jonathanpeppers added a commit to jonathanpeppers/diagnostics that referenced this pull request Aug 6, 2025
This is WIP, I have a TODO list at the bottom.

This enables you to do:

    dotnet-trace collect --dsrouter android -- dotnet build MyApp.csproj -t:Run -c Release -p:DiagnosticSuspend=false

Where `-p:DiagnosticSuspend=false` is optional.

What this does:

* `dotnet-trace` starts

* `dotnet-trace` launches `dotnet-dsrouter` passing the `--` unmatched
  args along.

* `dotnet-dsrouter` appends additional MSBuild properties if it
  detects the unmatched args are a `dotnet build` or `dotnet run`
  commands

* `dotnet-dsrouter` launches the command for the unmatched args.

~~ TODO ~~

- [ ] Merge this one first: dotnet#5535

- [ ] Figure out how we show progress. `dotnet build -t:Run` can take
  30 seconds+, so it seems like we somehow need to let the terminal
  logger show progress? Not sure how that can work.

- [ ] Switches after the `--` must be quoted in some cases: `'-t:Run'`
  for example. This is also a problem with plain `dotnet-trace`. This
  could maybe be addressed in a separate PR.
@jonathanpeppers jonathanpeppers marked this pull request as ready for review September 15, 2025 14:05
@jonathanpeppers jonathanpeppers requested a review from a team as a code owner September 15, 2025 14:05
@jonathanpeppers
Copy link
Member Author

@lateralusX @steveisok we released the above MSBuild properties in .NET 10 RC 1 / .NET 9 servicing last week.

So, I think we can update the instructions in dsrouter to use these now.

@steveisok steveisok merged commit 3c25a8b into main Sep 16, 2025
19 checks passed
@steveisok steveisok deleted the dev/peppers/dsrouter-instructions branch September 16, 2025 13:10
@github-actions github-actions bot locked and limited conversation to collaborators Oct 17, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants