Skip to content

[MTP Reporters Analysis] HtmlReport rejects path-valued --report-html-filename #8413

@Evangelink

Description

@Evangelink

Summary

HtmlReport rejects path-valued --report-html-filename arguments even though the HTML engine already writes through Path.Combine(outputDirectory, fileName). This makes HTML inconsistent with TRX and blocks report-path customization for the HTML reporter.

Evidence

  • src/Platform/Microsoft.Testing.Extensions.HtmlReport/HtmlReportGeneratorCommandLine.cs:45-50
    if (!IsValidPureFileName(fileName))
    {
        return ValidationResult.InvalidTask(ExtensionResources.HtmlReportFileNameShouldNotContainPath);
    }
  • src/Platform/Microsoft.Testing.Extensions.HtmlReport/HtmlReportEngine.cs:65-70
    string fileName = fileNameExplicitlyProvided
        ? providedFileName![0]
        : BuildDefaultFileName(finishTime);
    
    string outputDirectory = _configuration.GetTestResultDirectory();
    string finalPath = Path.Combine(outputDirectory, fileName);
  • For comparison, src/Platform/Microsoft.Testing.Extensions.TrxReport/TrxCommandLine.cs:45-48 explicitly allows relative or absolute paths for --report-trx-filename.

Why this is a real issue

A command like --report-html --report-html-filename subdir\report.html fails validation today, while the analogous TRX scenario is supported. The HTML engine would already place a relative path under the results directory (and Path.Combine would also honor rooted paths), so the current restriction is a CLI-only inconsistency that blocks a concrete customization scenario.

Suggested resolution

Align --report-html-filename with TRX semantics:

  • allow relative and absolute paths,
  • sanitize/validate only the leaf file name,
  • create missing intermediate directories before writing.

Related issues

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/mtp-extensionsMTP extensions (TrxReport, Retry, HtmlReport, ...).type/automationCreated or maintained by an agentic workflow.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions