Repository navigation
Description
Summary
The only way to currently customize the .trx filename when using MTP with the Microsoft.Testing.Extensions.TrxReport extension is by using the much more general purpose TestingPlatformCommandLineArguments MSBuild property.
I believe forcing the use of this single property makes for a more convoluted configuration experience and creates maintenance/flexibility issues for consumers.
A dedicated, more specific property should be provided that only concerns itself with the format of the trx file and nothing else.
Background and Motivation
We integrated .trx-based test reports in our GitHub workflows this week and it was a pain to get things to how we wanted. The current defaults for the file name are, in my opinion, awful, so we wanted to change them to something that would be more readable to the outside.
We used the dorny/test-reporter GitHub action to parse the .trx files from each of our projects and generate the test report. The tool relies on the filename to produce the various sections in its report (which by itself makes sense).
We made it work by configuring the TestingPlatformCommandLineArguments property like this:
<TestingPlatformCommandLineArguments>--report-trx --report-trx-filename $(MSBuildProjectName).trx</TestingPlatformCommandLineArguments>Which worked, but with some caveats.
The main issue is that this basically forces us to now always output a trx report, even when we don't want to. Because the way these properties work (as cmdline arguments) it is not possible to only specify --report-trx-filename, otherwise dotnet test will crash with an error saying that --report-trx-filename must be used in conjunction with --report-trx.
From a CLI tool's perspective, this is very reasonable, but because the CLI argument list is the only way to customize those values, it now becomes impossible to just change the format of the trx filenames without having to introduce the extra parameters and without forcing the entire command to always run.
Rather, what we really wanted, was to be able to customize just the format of the filename without touching anything else, and we wanted it to apply only when actually requesting a trx report, which we were trying to setup only in our GitHub workflows, not locally.
Yes, it is possible to add a MSBuild Condition to that property with something like:
<TestingPlatformCommandLineArguments Condition="'$(GITHUB_ACTIONS)' == 'true'">--report-trx --report-trx-filename $(MSBuildProjectName).trx</TestingPlatformCommandLineArguments>But at the end of the day, we decided against that as it was a bit too obscure. We opted for the less-than-ideal approach of "always generate the trx whenever running dotnet test" even though our need was only to do it on server builds.
The fact that it is all cmdline-based also prevents us from attempting something like this, which would be a much cleaner way of handling this (pseudo-code):
<TestingPlatformCommandLineArguments Condition="'$(cmdline_args).Include('--report-trx')">--report-trx-filename $(MSBuildProjectName).trx</TestingPlatformCommandLineArguments>Because msbuild does not have access to the passed-in cmdline arguments to dotnet test.
We think this would be significantly simpler if there was a dedicated MSBuild property that only concerned itself with the default format of the trx filenames, so that we could set only that, like:
<TrxFileNameFormat>$(MSBuildProjectName)</TrxFileNameFormat>And then, whenever --report-trx was used, it would just honor this value automatically, so we could be more explicit on the build server using:
dotnet test -- --report-trxAnd avoid the unnecessary process from just happening locally for everyone.
Proposed Feature
I propose that a dedicated MSBuild property be created to customize just the format of the filename for .trx files created by Microsoft.Testing.Extensions.TrxReport.
Suggested property name: TrxFileNameFormat
The commandline value, if specified, would still have precedence over this variable, since it is the more direct/explicit setting.
Alternative Designs
I don't see any other approaches that would be as clean as a dedicated MSBuild property for this. This approach allows using the full breadth of options that MSBuild provides including project-specific properties (such as the one we used, $(MSBuildProjectName)) to customize the format in a generic fashion especially in conjunction with a localized Directory.Build.props file.
Such customization is not possible directly at the commandline when we are running dotnet test because that is usually fired in a much broader context (we are calling it with no solution/project arguments so it grabs the default master solution of the entire repo).
At the same time, the existing TestingPlatformCommandLineArguments also doesn't allow us to cleanly override individual aspects of the generation such as the trx filename without forcing us into a whole other set of decisions.
I think this is preferred to other options such as the one described here:
Although I could see both working in conjunction as well as they feel like independent enhancements.
Activity
Youssef1313 commentedon Oct 1, 2025
I don't think it's a good idea to attempt to let the platform read MSBuild properties at runtime.
The only viable way I can think of to do this is by using
RuntimeHostConfigurationOption.TestingPlatformCommandLineArgumentsis kinda different. It's not read by MTP at runtime at all. It's simply a way to adjust how the exe is run in the first place, so the exe starts right away with the expected command-line arguments, and then MTP just reads those arguments.Currently,
TestingPlatformCommandLineArgumentsis the recommended way if you want to adjust TRX name.julealgon commentedon Oct 2, 2025
Youssef Fahmy (@Youssef1313) if msbuild properties is not feasible directly, there must be some other way of handling this. What about propagating environment variables to the MTP executable and customize these values through that?
julealgon commentedon Nov 24, 2025
Youssef Fahmy (@Youssef1313) what if I need to run my tests using
dotnet test --test-modules?I just realized that using that approach, none of the values declared in
TestingPlatformCommandLineArgumentsare honored at all, and we are back to square one: we need to run multiple testdll's, but we can't customize each outputtrxfile based on the executing project, since the CLI has no context of that.Now we are kinda stuck with the terrible default names of
trxfiles 😞My assumption is that something like this:
--report-trx-filename#5364Would resolve my problem.
Evangelink commentedon May 16, 2026
Juliano Leal Goncalves (@julealgon) I don't know if you are still using MTP. If you do, we just implemented the template (not yet shipped), I'd like to get your view on what would be missing for you.
julealgon commentedon May 18, 2026
We absolutely are still using MTP and this is still very relevant Amaury Levé (@Evangelink). Where can I find more info/docs on the proposed implementation?
Evangelink commentedon Aug 31, 2026
Juliano Leal Goncalves (@julealgon) Sorry for the very late reply... I completely missed your message.
The filename-template support I mentioned has now shipped in Microsoft.Testing.Platform 2.3.0. Instead of introducing a dedicated MSBuild property, we added runtime placeholders to report filenames. This also works when using
dotnet test --test-modules, where per-project MSBuild properties are not available because MTP is executing already-built test modules.For example:
dotnet test --test-modules <pattern> -- --report-trx --report-trx-filename "{asm}.trx"{asm}is replaced with each test module's assembly name. Other placeholders include{tfm},{arch},{pname},{pid}, and{time}. The full documentation is here: https://learn.microsoft.com/dotnet/core/testing/microsoft-testing-platform-test-reports#report-file-namesI'd really appreciate your feedback on this approach. Does it cover your original scenario? If you still need a dedicated MSBuild property, could you share the specific scenario or values that the template placeholders do not cover? That will help us design the right solution rather than adding a property that only addresses part of the need.
julealgon commentedon Aug 31, 2026
evangelik it covers some of our use cases, but is not ideal.
The fact that it is done through CLI arguments forces us to replicate those same arguments on every single one of our repositories.
We already have our own custom MSBuild SDK for test projects where we standardize all aspects of test projects across the whole company, such as common MSBuild properties, assertion library, test framework, mocking library, etc. If these settings were exposed as MSBuild properties, we would be able to standardize them as well without having to manually update dozens of GitHub actions workflows across the organization.
Also note that I'm aware there is a MSBuild property to override the commandline arguments for the
dotnet testcall, but that does not work well for setting defaults as it always propagates the extra command, which is really not what we want at all.Lastly, that solution doesn't cover other aspects which we also override today, such as
--coverage-outputand--coverage-output-formatvalues.Basically, as it is, we currently cannot migrate to this approach without loss of capability on our side. I guess we could instead more our standardization into a custom shared GitHub composite action where we wrap
dotnet testbut that feels significantly more convoluted, and would still require us to update every single workflow in the company to use the new composite action.I would still strongly recommend reconsidering here and exposing some of these defaults as MSBuild properties.
You can keep the CLI templating thing but it would be built on top of the MSBuild properties. They are mostly independent mechanisms.
Evangelink commentedon Aug 31, 2026
Juliano Leal Goncalves (@julealgon) Thanks, I think I understand the distinction now: you want to centralize defaults without those defaults enabling the corresponding feature.
Would entries in
testconfig.jsonsolve this for your custom SDK? We are considering a generic mechanism that any extension could use, rather than adding an MSBuild property for every option. For example:{ "commandLineOptionDefaults": { "report-trx-filename": "{asm}.trx", "coverage-output": "{asm}.coverage", "coverage-output-format": "cobertura" } }The keys would match CLI option names without
--. These values would be passive defaults: they would not enable--report-trxor--coverage, and an explicit CLI value would take precedence. Because the configuration travels with the built test module, this should also work withdotnet test --test-modules.If a JSON file cannot be supplied centrally by your SDK, we could also consider an MSBuild item that projects these entries into the module configuration, along these lines:
Would the
testconfig.jsonapproach cover your centralization scenario, or is an MSBuild-facing entry point necessary for how your SDK is distributed?julealgon commentedon Aug 31, 2026
evangelik
Exactly.
Using
testconfig.jsonwould also work for us. We actually already provide one as part of our custom SDK as well, so this would be a matter of adding the extra properties there.No concerns from my end if the team prefers this approach over MSBuild properties.
Evangelink commentedon Sep 1, 2026
Juliano Leal Goncalves (@julealgon) it will be available in 2.4 releasing by EOW.