@@ -33,15 +33,44 @@ public static int CmdExecute(string command, string workingDirectoryPath, bool o
3333
3434 if ( output )
3535 {
36- cmd . OutputDataReceived += ( s , e ) => Console . WriteLine ( e . Data ) ;
36+ cmd . OutputDataReceived += ( s , e ) =>
37+ {
38+ // (sometimes error messages are only visbile here)
39+ // poor mans solution, we just seek for the term 'error'
40+
41+ // we can't just use cmd.ExitCode, because
42+ // we delegate it to cmd.exe, which runs fine
43+ // but we can catch any error here and return
44+ // 1 if something fails
45+ if ( e != null && string . IsNullOrWhiteSpace ( e . Data ) == false )
46+ {
47+ if ( e . Data . ToLowerInvariant ( ) . Contains ( "error" ) )
48+ {
49+ returnCode = 1 ;
50+ }
51+
52+ Console . WriteLine ( e . Data ) ;
53+ }
54+
55+ } ;
3756 cmd . ErrorDataReceived += ( s , e ) =>
3857 {
58+ // poor mans solution, we just seek for the term 'error'
59+
3960 // we can't just use cmd.ExitCode, because
4061 // we delegate it to cmd.exe, which runs fine
4162 // but we can catch any error here and return
4263 // 1 if something fails
43- returnCode = 1 ;
44- Console . WriteLine ( e . Data ) ;
64+ if ( e != null && string . IsNullOrWhiteSpace ( e . Data ) == false )
65+ {
66+ if ( e . Data . ToLowerInvariant ( ) . Contains ( "error" ) )
67+ {
68+ returnCode = 1 ;
69+ }
70+
71+ Console . WriteLine ( e . Data ) ;
72+ }
73+
4574 } ;
4675 }
4776
0 commit comments