Skip to content

[dotnet watch] Add --trace command line switch - #56008

Merged
tmat merged 8 commits into
dotnet:mainfrom
tmat:tmat-dotnet-watch-trace
Sep 9, 2026
Merged

tmat merged 8 commits into
dotnet:mainfrom
tmat:tmat-dotnet-watch-trace

Conversation

@tmat

@tmat tmat commented Aug 28, 2026 •

Copy link
Copy Markdown
Member

Adds an explicit --trace switch to dotnet watch to enable LogLevel.Trace, keeps --verbose as LogLevel.Debug, and removes the prior special-casing where DOTNET_CLI_CONTEXT_VERBOSE=trace enabled Trace logging.

Changes:

  • Add --trace option to the dotnet watch CLI (including mutual-exclusion validation with --quiet/--verbose).
  • Stop interpreting DOTNET_CLI_CONTEXT_VERBOSE=trace as LogLevel.Trace (now only boolean -> LogLevel.Debug).
  • Update test utilities and command-line parsing tests to use/validate --trace, plus add localized help text.

We intentionally separate controls of dotnet-watch log level (--quiet, --verbose and --trace) from --verbosity option that controls the verbosity of subcommands to separate diagnosing Hot Reload issues from diagnosing issues related to the subcommand (e.g. build, restore, etc.)

tmat added 2 commits August 28, 2026 14:37
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: a89a64b5-e312-44e2-8650-9e2e0906dee8
Copilot AI lite review requested due to automatic review settings August 28, 2026 21:45
@tmat
tmat requested a review from a team as a code owner August 28, 2026 21:45
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).
2 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

@tmat

tmat commented Aug 28, 2026

Copy link
Copy Markdown
Member Author

@genlu

@tmat
tmat enabled auto-merge (squash) August 28, 2026 21:57

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds an explicit --trace switch to dotnet watch to enable LogLevel.Trace, keeps --verbose as LogLevel.Debug, and removes the prior special-casing where DOTNET_CLI_CONTEXT_VERBOSE=trace enabled Trace logging.

Changes:

  • Add --trace option to the dotnet watch CLI (including mutual-exclusion validation with --quiet/--verbose).
  • Stop interpreting DOTNET_CLI_CONTEXT_VERBOSE=trace as LogLevel.Trace (now only boolean -> LogLevel.Debug).
  • Update test utilities and command-line parsing tests to use/validate --trace, plus add localized help text.

Reviewed changes

Copilot reviewed 19 out of 19 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
test/Microsoft.DotNet.HotReload.Test.Utilities/WatchableApp.cs Switch test harness default from env-var trace to --trace, and remove env-var injection.
test/dotnet-watch.Tests/CommandLine/CommandLineOptionsTests.cs Add coverage for --trace parsing and conflicts with other log-level options.
src/Dotnet.Watch/Watch/Context/EnvironmentVariables.cs Remove trace string handling from DOTNET_CLI_CONTEXT_VERBOSE mapping.
src/Dotnet.Watch/dotnet-watch/xlf/Resources.zh-Hant.xlf Add localized help entry for Help_Trace.
src/Dotnet.Watch/dotnet-watch/xlf/Resources.zh-Hans.xlf Add localized help entry for Help_Trace.
src/Dotnet.Watch/dotnet-watch/xlf/Resources.tr.xlf Add localized help entry for Help_Trace.
src/Dotnet.Watch/dotnet-watch/xlf/Resources.ru.xlf Add localized help entry for Help_Trace.
src/Dotnet.Watch/dotnet-watch/xlf/Resources.pt-BR.xlf Add localized help entry for Help_Trace.
src/Dotnet.Watch/dotnet-watch/xlf/Resources.pl.xlf Add localized help entry for Help_Trace.
src/Dotnet.Watch/dotnet-watch/xlf/Resources.ko.xlf Add localized help entry for Help_Trace.
src/Dotnet.Watch/dotnet-watch/xlf/Resources.ja.xlf Add localized help entry for Help_Trace.
src/Dotnet.Watch/dotnet-watch/xlf/Resources.it.xlf Add localized help entry for Help_Trace.
src/Dotnet.Watch/dotnet-watch/xlf/Resources.fr.xlf Add localized help entry for Help_Trace.
src/Dotnet.Watch/dotnet-watch/xlf/Resources.es.xlf Add localized help entry for Help_Trace.
src/Dotnet.Watch/dotnet-watch/xlf/Resources.de.xlf Add localized help entry for Help_Trace.
src/Dotnet.Watch/dotnet-watch/xlf/Resources.cs.xlf Add localized help entry for Help_Trace.
src/Dotnet.Watch/dotnet-watch/Resources.resx Add Help_Trace resource string used by --trace option help text.
src/Dotnet.Watch/dotnet-watch/CommandLine/DotnetWatchCommandDefinition.cs Define/register --trace option and enforce mutual exclusion with other log-level options.
src/Dotnet.Watch/dotnet-watch/CommandLine/CommandLineOptions.cs Map --trace to LogLevel.Trace during options parsing.
Suppressed comments (1)

src/Dotnet.Watch/dotnet-watch/CommandLine/CommandLineOptions.cs:149

  • --trace sets options.GlobalOptions.LogLevel to Trace, but Program.TryCreate (and AspireLauncher) currently uses environmentOptions.CliLogLevel ?? options.GlobalOptions.LogLevel. If DOTNET_CLI_CONTEXT_VERBOSE is set (even just true), it forces Debug and will override --trace, so users can't actually get Trace output in that environment. Consider changing the effective log level selection to prefer the more-verbose of the two (e.g., Trace wins over Debug) or to make explicit CLI flags override the environment setting.
        var logLevel = parseResult.GetValue(definition.TraceOption)
            ? LogLevel.Trace
            : parseResult.GetValue(definition.VerboseOption)
            ? LogLevel.Debug
            : parseResult.GetValue(definition.QuietOption)
            ? LogLevel.Warning
            : LogLevel.Information;

tmat added 3 commits August 28, 2026 15:17
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: a89a64b5-e312-44e2-8650-9e2e0906dee8
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: a89a64b5-e312-44e2-8650-9e2e0906dee8
@marcpopMSFT marcpopMSFT added the Area-Watch dotnet-watch label Sep 1, 2026
@tmat
tmat requested a review from a team as a code owner September 2, 2026 04:55
@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

🔍 Build Failure Analysis — the binlog-mcp analysis service was unresponsive for this run (every tool call, including trivial non-file operations like binlog_capabilities and list_mcp_instances, timed out with context deadline exceeded across all 20 build legs after multiple retries). No error data could be extracted from the binlogs this way.

Please see the originating [Azure DevOps build]((dev.azure.com/redacted) for the authoritative build logs (this workflow reuses that build's binlogs and does not build locally). The GitHub Actions run has the fetch-step diagnostics.

🤖 Automated content by GitHub Copilot. Generated by the Build Failure Analysis workflow. · auto · 46.7 AIC · ⌖ 1.77 AIC · ⊞ 7.1K · [◷]( · ◷)

@tmat
tmat force-pushed the tmat-dotnet-watch-trace branch from 551352e to 072515a Compare September 8, 2026 14:36
@tmat

tmat commented Sep 8, 2026

Copy link
Copy Markdown
Member Author

/backport to release/11.0.1xx

@github-actions

github-actions Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Started backporting to release/11.0.1xx (link to workflow run)

@github-actions

github-actions Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

@tmat backporting to release/11.0.1xx was not run because the source pull request has not been merged. Please merge this pull request before requesting a backport.

@tmat
tmat merged commit 79546a8 into dotnet:main Sep 9, 2026
28 checks passed
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 12.0-preview1 milestone Sep 9, 2026
@github-actions

github-actions Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Started backporting to release/11.0.1xx (link to workflow run)

tmat added a commit that referenced this pull request Sep 15, 2026
Copilot-Session: a89a64b5-e312-44e2-8650-9e2e0906dee8

This branch had an error being deployed

1 failed deployment
copilot-pat-pool — 072515a7 Deployed Sep 9, 2026 by tmat via pre_activation #3515
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area-Watch dotnet-watch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants