Skip to content

Add --report-dir option and reportsFolder setting for report output - #2099

Open
waldekmastykarz wants to merge 1 commit into
dotnet:mainfrom
waldekmastykarz:add-report-dir-option
Open

waldekmastykarz wants to merge 1 commit into
dotnet:mainfrom
waldekmastykarz:add-report-dir-option

Conversation

@waldekmastykarz

Copy link
Copy Markdown
Collaborator

Resolves #2071

Problem

Reporters wrote reports to a relative file name, so they always landed in Dev Proxy's current working directory. Scripts that wanted reports elsewhere had to start Dev Proxy with a different cwd, which also changes how relative config paths and devproxyrc.json discovery resolve.

Changes

  • reportsFolder setting in devproxyrc.json. Relative paths resolve against the config file's folder (like other paths in config files); ~/, ~appFolder, and ~dataFolder tokens are supported.
  • --report-dir <path> CLI option. Relative paths resolve against the current working directory (standard CLI behavior) and override reportsFolder. Rejects a path that points to an existing file.
  • BaseReporter (Json, Markdown, PlainText reporters) writes to that folder and creates it if needed. The existing "file exists → append timestamp" behavior is preserved inside the folder. Default is unchanged: the working directory.
  • IProxyConfiguration.ReportsFolder added; BaseReporter gets a new constructor overload taking IProxyConfiguration. The original constructor is kept so third-party reporters keep compiling (they keep writing to the cwd).
  • schemas/v4.0.0/rc.schema.json documents reportsFolder.

Scope note

Generator plugins (HAR, mocks, OpenAPI, TypeSpec, .http) also write files to the cwd. I left them out to keep this PR to the reporters the issue calls out; happy to follow up if we want them to honor the same folder.

Testing

  • Unit tests for config-relative resolution, absolute paths, unset value, and --report-dir resolution (incl. ~/).
  • Integration tests: report written into a (missing, nested) reports folder and not the cwd; timestamp suffix when the file exists; cwd fallback when unset.
  • Manual e2e: reportsFolder in config → report lands next to the config file; --report-dir with --detach → report lands relative to the invoking cwd.

Reporters wrote reports to Dev Proxy's current working directory, forcing
scripts to change cwd (which also changes how config paths resolve) just
to control where reports land.

- New reportsFolder setting in devproxyrc.json, resolved relative to the
  config file (supports ~/, ~appFolder, ~dataFolder tokens)
- New --report-dir option, resolved relative to the working directory,
  which overrides reportsFolder
- BaseReporter writes to the folder (creating it if needed); default stays
  the working directory
- Updated v4.0.0 rc schema

Closes dotnet#2071

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@waldekmastykarz
waldekmastykarz requested a review from a team as a code owner November 5, 2026 10:47
Copilot AI balanced review requested due to automatic review settings November 5, 2026 10:47

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.

🟢 Approval recommended

No active review issues are recorded for the configurable reporter output-folder change.

No open issues 🎉

What changed in this PR

Adds configurable output folders for Dev Proxy reporters without changing the working directory or config discovery behavior.

Changes:

  • Adds reportsFolder and the overriding --report-dir option, with config-relative and working-directory-relative path resolution respectively.
  • Updates JSON, Markdown, and plain-text reporters to create and use the selected folder while preserving timestamp suffixes and the default working-directory behavior.
  • Adds unit and integration coverage for path resolution and report output.
File Description
schemas/​v4.0.0/​rc.schema.json Documents the reportsFolder setting.
DevProxy/​Proxy/​ProxyConfiguration.cs Resolves configured report paths relative to the config file.
DevProxy/​Commands/​DevProxyCommand.cs Adds, validates, and applies --report-dir.
DevProxy.Tests/​ReportsFolderTests.cs Tests config and CLI path resolution.
DevProxy.Tests/​Fakes.cs Adds the report-folder property to the test fake.
DevProxy.Plugins/​Reporters/​PlainTextReporter.cs Passes proxy configuration to the base reporter.
DevProxy.Plugins/​Reporters/​MarkdownReporter.cs Passes proxy configuration to the base reporter.
DevProxy.Plugins/​Reporters/​JsonReporter.cs Passes proxy configuration to the base reporter.
DevProxy.Plugins/​Reporters/​BaseReporter.cs Creates and uses the output folder; retains the original constructor.
DevProxy.Integration.Tests/​TestProxyConfiguration.cs Adds report-folder support to integration test configuration.
DevProxy.Integration.Tests/​ReporterReportsFolderTests.cs Tests folder creation, timestamp suffixes, and working-directory fallback.
DevProxy.Integration.Tests/​JsonReporterTests.cs Updates reporter construction to supply configuration.
DevProxy.Abstractions/​Proxy/​IProxyConfiguration.cs Exposes the report output folder in the configuration contract.

Review effort: Balanced

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add a --report-dir option and config setting for report output

2 participants