Skip to content

Allow placeholders in --report-trx-filename #5364

Description

Summary

Allow placeholders in --report-trx-filename. So, users can do --report-trx-filename MyFile_<target_framework>.trx

Background and Motivation

In VSTest, LogFilePrefix was supported. This is something we currently lack in MTP.

Proposed Feature

A more flexible solution, to allow placeholders in --report-trx-filename.

We can start with the following placeholders:

<assembly_name>
<target_framework>
<timestamp>
<process_id>

Alternative Designs

Add a new command-line option, --report-trx-file-prefix. Only one of --report-trx-filename and --report-trx-file-prefix can be used at the same time.
But placeholders can be more flexible.

Activity

  1. added
    area/mtp
    area/mtp-extensions
    area/trx
    on Apr 3, 2025
  2. Youssef1313 commented on Apr 3, 2025

    @Youssef1313
    MemberAuthor

    <target_framework> isn't super trivial. It doesn't seem easy (or possible at all?) to know net9.0 vs net9.0-windows for example. I don't want us to introduce something that's not accurate.

    Maybe instead, we can expose <target_framework_identifier> (.NETFramework, .NETCoreApp, etc). And <target_framework_version>.

    In that case, yes it will be the same for net9.0 and net9.0-windows, but that's what we expose and what the names refer to.

  3. nohwnd commented on Apr 4, 2025

    @nohwnd
    Member

    these two assembly level attributes have that info:

    [assembly: TargetPlatform("Windows10.0.26100.0")]
    [assembly: SupportedOSPlatform("Windows10.0.26100.0")]

    When the value is Windows7.0 or 8.0, that is the -windows value. Otherwise the exact version is used.

    The mapping is defined here: https://github.com/dotnet/sdk/blob/main/src/Layout/redist/targets/GenerateBundledVersions.targets#L1313-L1337

    We already have some code that translates the TFM to short names, and this would be a good adition there, so we don't have to show .NETCoreApp,Version=7.0.0 to users, or whatever horrible name is in the framework identifier.

  4. nohwnd commented on May 23, 2025

    @nohwnd
    Member

    Suggestion to further improve this, to choose the shortest names for the most used properties:

    tfm -> net9.0
    timestamp -> date + time with seconds accuracy in sortable format 2025-05-23T17-45-56
    id / rng -> short random id like f0fJf that is just enough to guarantee that we don't get the conflict on seconds / minutes
    assembly / project -> project name -> ContonsoTests

    pid -> process id

    date -> just date in sortable format
    time -> just time in sortable format

    repo_root -> place where there is .git or .sln ?
    etc.

    and then some other longer replacements: guid, precise_time, long_tfm based on the needs that we discover.

    Also we should document when and where we take the values from, e.g. if we would rely on current folder, we should resolve it before the run and document that, to avoid leaving it after the run when tests can change the current folder etc.

  5. Evangelink commented on Jul 15, 2025

    @Evangelink
    Member

    Relates to #4130 for the format of placeholders.

    Browsing the most common patterns in .NET, it seems we have:

    • $(Variable) like MSBuild
    • $var$ like templating engines (VS and dotnet)
    • ${var} like most shell

    Chet Husk (@baronfel) with your experience in SDK and your broad view over the products, is there a pattern you would recommend?

  6. baronfel commented on Jul 15, 2025

    @baronfel
    Member

    I'd strongly encourage you to not do MSBuild-style placeholders - we don't expose MSBuild stuff anywhere else on the CLI directly. There is a small amount of prior art for the -bl flag in MSbuild - it accepts {} in the name and will expand it with the current timestamp formatted in a lexically-sortable way.

  7. RussKie commented on Mar 25, 2026

    @RussKie

    Bumping the issue to reiterate the need for the customisation. Running dotnet test <name>.sln -- --results-directory "$(path)\TestsResults" --report-trx --report-trx-filename test_results.trx results in a trx from the last tested project, all others stomped over...

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

Metadata

Metadata

Labels

area/mtparea/mtp-extensionsarea/trx

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions