Skip to content

TRX logger generates inconsistent attachment paths if "LogFileName" contains a folder #15271

@gasparnagy

Description

@gasparnagy

I have a test that attaches an a file to the result as test attachment.

When I invoke the tests with dotnet test --logger trx, a TRX file is generated into the TestResults, with content like:

<?xml version="1.0" encoding="utf-8"?>
<TestRun id="4331b725-7dd8-4bf1-8f2d-5172f4badc2a" name="gaspar@SPECSOL-D02 2025-09-01 12:41:46" runUser="SPECSOL-D02\gaspar" xmlns="http://microsoft.com/schemas/VisualStudio/TeamTest/2010">
  <TestSettings name="default" id="42cb1c37-a94c-47b4-a25d-b407aecac057">
    <Deployment runDeploymentRoot="gaspar_SPECSOL-D02_2025-09-01_12_41_46" />
  </TestSettings>
  <Results>
    <UnitTestResult executionId="933251df-f80e-4822-9a1c-f424a6a29418" testId="4b94be94-1b4e-0dc0-394e-895a6466b9fd" testName="[...]" computerName="SPECSOL-D02" duration="00:00:00.0002259" startTime="2025-09-01T12:41:46.2170389+02:00" endTime="2025-09-01T12:41:46.2173424+02:00" testType="13cdc9d9-ddb5-4fa4-a97d-d965ccfc6d4b" outcome="Passed" testListId="8c84fa94-04c1-424b-9868-57a2d4851a1d" relativeResultsDirectory="933251df-f80e-4822-9a1c-f424a6a29418">
      <ResultFiles>
        <ResultFile path="SPECSOL-D02\sample-image.png" />
      </ResultFiles>
    </UnitTestResult>
  </Results>
  [...]
</TestRun>

Based on the TRX file, the attachment is correctly saved to C:\MyProject\TestResults\gaspar_SPECSOL-D02_2025-09-01_12_41_46\In\933251df-f80e-4822-9a1c-f424a6a29418\SPECSOL-D02\sample-image.png because

  • C:\MyProject\TestResults\ (because the TRX file is here) +
  • gaspar_SPECSOL-D02_2025-09-01_12_41_46 (because of runDeploymentRoot) +
  • In (fix part) +
  • 933251df-f80e-4822-9a1c-f424a6a29418 (because of relativeResultsDirectory) +
  • SPECSOL-D02\sample-image.png (because of ResultFile path)

This is correct.

If I use a folder when specifying the LogFileName setting (this seems to be allowed based on the doc), the result is inconsistent:

  • The TRX file is saved to the specified target location
  • The attachments are saved to the TestResults folder of the project
  • The TRX file runDeploymentRoot does not have a reference to the attachment save location

I would expect that in this case, the <Deployment runDeploymentRoot="gaspar_SPECSOL-D02_2025-09-01_12_41_46" /> is updated accordingly.

Note: If I don't use folder path for LogFileName, but just a file path and use --results-directory to specify the output folder, everything works fine.

Metadata

Metadata

Assignees

No one assigned

    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