Skip to content

[dotnet-trace/dsrouter] simplify mobile tracing to a one-liner!#5542

Closed
jonathanpeppers wants to merge 2 commits intodotnet:mainfrom
jonathanpeppers:dev/peppers/dsrouter-unmatched-tokens
Closed

[dotnet-trace/dsrouter] simplify mobile tracing to a one-liner!#5542
jonathanpeppers wants to merge 2 commits intodotnet:mainfrom
jonathanpeppers:dev/peppers/dsrouter-unmatched-tokens

Conversation

@jonathanpeppers
Copy link
Copy Markdown
Member

@jonathanpeppers jonathanpeppers commented 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: [dsrouter] improved instructions/log messages #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.

  • For iOS, we may want to pass -p:_MlaunchWaitForExit=false so
    that it doesn't block on console output. That would mean we might
    also want the MSBuild property to be public.

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`.
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
Copy link
Copy Markdown
Member Author

Will revisit this in the future.

@github-actions github-actions Bot locked and limited conversation to collaborators Feb 20, 2026
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.

1 participant