Summary
A single missing or inaccessible attachment can abort the entire TRX generation path. The reporter currently treats attachment copy failures as fatal instead of skipping the bad attachment and still producing the TRX.
Evidence
- Per-test attachments are copied during report generation in
src/Platform/Microsoft.Testing.Extensions.TrxReport/TrxReportEngine.Results.cs:160-170
foreach (TrxTestFileArtifact testFileArtifact in testResult.FileArtifacts)
{
resultFiles ??= new XElement("ResultFiles");
string href = CopyArtifactIntoTrxDirectoryAndReturnHrefValue(new FileInfo(testFileArtifact.FullPath), runDeploymentRoot, executionId);
resultFiles.Add(new XElement(
"ResultFile",
new XAttribute("path", href)));
}
- The copy helper performs an unchecked copy in
src/Platform/Microsoft.Testing.Extensions.TrxReport/TrxReportEngine.Artifacts.cs:83-85
_fileSystem.CopyFile(artifact.FullName, new FileInfo(destination).FullName);
return Path.Combine(_environment.MachineName, Path.GetFileName(destination));
- The session-finish path awaits report generation directly in
src/Platform/Microsoft.Testing.Extensions.TrxReport/TrxDataConsumer.cs:223-223
(string reportFileName, string? warning) = await GenerateReportAndCleanupAsync(trxReportGeneratorEngine, cancellationToken).ConfigureAwait(false);
and GenerateReportAndCleanupAsync just forwards engine.GenerateReportAsync(...) (TrxDataConsumer.cs:337-340).
Why this is a real issue
If a test attaches a temp file and deletes it before session end, or if a copy hits UnauthorizedAccessException / IOException, that exception bubbles out of TRX generation. The result is that one bad attachment can prevent the run from producing any TRX file, even though the rest of the test results are valid.
Suggested resolution
Handle attachment copy failures per artifact:
- catch copy/open exceptions around the individual attachment,
- emit a warning /
RunInfo entry describing the skipped artifact,
- continue generating the TRX for the rest of the run.
Related issues
Summary
A single missing or inaccessible attachment can abort the entire TRX generation path. The reporter currently treats attachment copy failures as fatal instead of skipping the bad attachment and still producing the TRX.
Evidence
src/Platform/Microsoft.Testing.Extensions.TrxReport/TrxReportEngine.Results.cs:160-170src/Platform/Microsoft.Testing.Extensions.TrxReport/TrxReportEngine.Artifacts.cs:83-85src/Platform/Microsoft.Testing.Extensions.TrxReport/TrxDataConsumer.cs:223-223GenerateReportAndCleanupAsyncjust forwardsengine.GenerateReportAsync(...)(TrxDataConsumer.cs:337-340).Why this is a real issue
If a test attaches a temp file and deletes it before session end, or if a copy hits
UnauthorizedAccessException/IOException, that exception bubbles out of TRX generation. The result is that one bad attachment can prevent the run from producing any TRX file, even though the rest of the test results are valid.Suggested resolution
Handle attachment copy failures per artifact:
RunInfoentry describing the skipped artifact,Related issues