@@ -66,17 +66,23 @@ public async Task OnTestHostProcessExitedAsync(ITestHostProcessInformation testH
6666 await _outputDisplay . DisplayAsync ( this , new ErrorMessageOutputDeviceData ( string . Format ( CultureInfo . InvariantCulture , CrashDumpResources . CrashDumpProcessCrashedDumpFileCreated , testHostProcessInformation . PID ) ) , cancellation ) . ConfigureAwait ( false ) ;
6767
6868 string expectedDumpFile = _netCoreCrashDumpGeneratorConfiguration . DumpFileNamePattern . Replace ( "%p" , testHostProcessInformation . PID . ToString ( CultureInfo . InvariantCulture ) ) ;
69- if ( File . Exists ( expectedDumpFile ) )
69+ string dumpDirectory = Path . GetDirectoryName ( expectedDumpFile ) ! ;
70+
71+ // Collect all dump files in the directory to capture crashes from child processes
72+ bool foundExpectedDump = false ;
73+ foreach ( string dumpFile in Directory . GetFiles ( dumpDirectory , "*.dmp" ) )
7074 {
71- await _messageBus . PublishAsync ( this , new FileArtifact ( new FileInfo ( expectedDumpFile ) , CrashDumpResources . CrashDumpArtifactDisplayName , CrashDumpResources . CrashDumpArtifactDescription ) ) . ConfigureAwait ( false ) ;
75+ if ( string . Equals ( dumpFile , expectedDumpFile , StringComparison . OrdinalIgnoreCase ) )
76+ {
77+ foundExpectedDump = true ;
78+ }
79+
80+ await _messageBus . PublishAsync ( this , new FileArtifact ( new FileInfo ( dumpFile ) , CrashDumpResources . CrashDumpArtifactDisplayName , CrashDumpResources . CrashDumpArtifactDescription ) ) . ConfigureAwait ( false ) ;
7281 }
73- else
82+
83+ if ( ! foundExpectedDump )
7484 {
7585 await _outputDisplay . DisplayAsync ( this , new ErrorMessageOutputDeviceData ( string . Format ( CultureInfo . InvariantCulture , CrashDumpResources . CannotFindExpectedCrashDumpFile , expectedDumpFile ) ) , cancellation ) . ConfigureAwait ( false ) ;
76- foreach ( string dumpFile in Directory . GetFiles ( Path . GetDirectoryName ( expectedDumpFile ) ! , "*.dmp" ) )
77- {
78- await _messageBus . PublishAsync ( this , new FileArtifact ( new FileInfo ( dumpFile ) , CrashDumpResources . CrashDumpDisplayName , CrashDumpResources . CrashDumpArtifactDescription ) ) . ConfigureAwait ( false ) ;
79- }
8086 }
8187 }
8288}
0 commit comments