Specifying results filename for vstest.console.exe

EDIT: See @AnaFranco’s answer – apparently since VS2017 the file name can be configured like so:

vstest.console.exe [assembly] /logger:trx;LogFileName=[filename].trx

I’ll leave the old answer for posterity and pre-2017 versions.


Nope, you’re not missing anything. The TRX logger doesn’t support any parameters (unlike the TFS publisher logger).

The logger assembly is located in "C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow\Extensions\Microsoft.VisualStudio.TestPlatform.Extensions.TrxLogger.dll". If you check it out in your favorite .NET decompiler, you’ll see the method TrxLogger.GetTrxFileName. It uses some basic knowledge about the current test run to produce the mangled name of form {username}_{workstation} {timestamp}.trx and is in no appreciable way configurable.

As far as I can tell, the TRX file is created in the TestResults\ folder under the current working directory unless otherwise configured. What you can do is:

  • Create a new temporary folder
  • Change the current directory to it
  • Run the test runner
  • Scan the folder for the result .trx file using your favorite recursive file search method and you’re done

At least that is what I do in our build (MSBuild, sob):

<ItemGroup>
  <TestResult Include="**\*.trx"/>
</ItemGroup>

I.e, gather all .trx files under the current directory and stuff them into the @(TestResult) item group for further processing.

Leave a Comment