@@ -34,20 +34,35 @@ private void Info()
34
34
}
35
35
}
36
36
37
- private bool RunCommand ( string args )
37
+ private static ProcessStartInfo MakeDotnetStartInfo ( string args ) =>
38
+ new ProcessStartInfo ( dotnet , args )
39
+ {
40
+ UseShellExecute = false ,
41
+ RedirectStandardOutput = true
42
+ } ;
43
+
44
+ private bool RunCommandAux ( string args , bool silent )
38
45
{
39
46
progressMonitor . RunningProcess ( $ "{ dotnet } { args } ") ;
40
- using var proc = Process . Start ( dotnet , args ) ;
41
- proc . WaitForExit ( ) ;
42
- if ( proc . ExitCode != 0 )
47
+ using var proc = silent
48
+ ? Process . Start ( MakeDotnetStartInfo ( args ) )
49
+ : Process . Start ( dotnet , args ) ;
50
+ proc ? . WaitForExit ( ) ;
51
+ var exitCode = proc ? . ExitCode ?? - 1 ;
52
+ if ( exitCode != 0 )
43
53
{
44
- progressMonitor . CommandFailed ( dotnet , args , proc . ExitCode ) ;
54
+ progressMonitor . CommandFailed ( dotnet , args , exitCode ) ;
45
55
return false ;
46
56
}
47
-
48
57
return true ;
49
58
}
50
59
60
+ private bool RunCommand ( string args ) =>
61
+ RunCommandAux ( args , false ) ;
62
+
63
+ private bool RunCommandSilently ( string args ) =>
64
+ RunCommandAux ( args , true ) ;
65
+
51
66
public bool RestoreToDirectory ( string projectOrSolutionFile , string packageDirectory , string ? pathToNugetConfig = null )
52
67
{
53
68
var args = $ "restore --no-dependencies \" { projectOrSolutionFile } \" --packages \" { packageDirectory } \" /p:DisableImplicitNuGetFallbackFolder=true";
@@ -75,11 +90,7 @@ public bool AddPackage(string folder, string package)
75
90
private IList < string > GetListed ( string args , string artifact )
76
91
{
77
92
progressMonitor . RunningProcess ( $ "{ dotnet } { args } ") ;
78
- var pi = new ProcessStartInfo ( dotnet , args )
79
- {
80
- RedirectStandardOutput = true ,
81
- UseShellExecute = false
82
- } ;
93
+ var pi = MakeDotnetStartInfo ( args ) ;
83
94
var exitCode = pi . ReadOutput ( out var artifacts ) ;
84
95
if ( exitCode != 0 )
85
96
{
@@ -92,9 +103,8 @@ private IList<string> GetListed(string args, string artifact)
92
103
93
104
public bool Exec ( string execArgs )
94
105
{
95
- // TODO: we might need to swallow the stdout of the started process to not pollute the logs of the extraction.
96
106
var args = $ "exec { execArgs } ";
97
- return RunCommand ( args ) ;
107
+ return RunCommandSilently ( args ) ;
98
108
}
99
109
}
100
110
}
0 commit comments