-
Notifications
You must be signed in to change notification settings - Fork 0
TC build fails to parse .trx file due to file lock #108
Copy link
Copy link
Open
Description
Summary
TeamCity builds frequently fail with a FileNotFoundException / file lock error when parsing .trx test result files. The TC XML report parser tries to read the .trx file while it is still being written by dotnet test, resulting in a The process cannot access the file because it is being used by another process error.
Error
Parsing errors
Failed to parse 1 report
artifacts\testResults\ContainerAdministrator_A094B04200D8_2026-03-31_11_03_38.trx:
C:\wk2\c33f66953b1f6eb\artifacts\testResults\ContainerAdministrator_A094B04200D8_2026-03-31_11_03_38.trx
(The process cannot access the file because it is being used by another process)
java.io.FileNotFoundException: ...
at jetbrains.buildServer.xmlReportPlugin.parsers.mstest.TRXParser.parse(TRXParser.java:152)
at jetbrains.buildServer.xmlReportPlugin.ParseReportCommand.run(ParseReportCommand.java:62)
Example build
https://postsharp.teamcity.com/buildConfiguration/Metalama_Metalama20261_Metalama_DebugBuild/322251
Analysis
The TC XML Report Processing build feature monitors the artifacts\testResults directory for .trx files. It appears to pick up the file while dotnet test is still writing to it, causing a file lock conflict. This is a race condition between the test runner and TC's report parser.
Possible fixes
- Add a delay or post-processing step so TC only parses
.trxfiles afterdotnet testcompletes - Configure the XML Report Processing build feature to use a different monitoring mode (e.g., parse on finish rather than on-the-fly)
- Copy
.trxfiles to a separate directory after tests complete and point TC at that directory - Use
--results-directorywith a temp path and copy toartifacts\testResultsonly after tests finish
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels