@@ -22,31 +22,24 @@ public DotNet(ProgressMonitor progressMonitor)
22
22
private void Info ( )
23
23
{
24
24
// TODO: make sure the below `dotnet` version is matching the one specified in global.json
25
- progressMonitor . RunningProcess ( $ "{ dotnet } --info") ;
26
- using var proc = Process . Start ( dotnet , "--info" ) ;
27
- proc . WaitForExit ( ) ;
28
- var ret = proc . ExitCode ;
29
-
30
- if ( ret != 0 )
25
+ var res = RunCommand ( "--info" ) ;
26
+ if ( ! res )
31
27
{
32
- progressMonitor . CommandFailed ( dotnet , "--info" , ret ) ;
33
- throw new Exception ( $ "{ dotnet } --info failed with exit code { ret } .") ;
28
+ throw new Exception ( $ "{ dotnet } --info failed.") ;
34
29
}
35
30
}
36
31
37
- private static ProcessStartInfo MakeDotnetStartInfo ( string args ) =>
32
+ private static ProcessStartInfo MakeDotnetStartInfo ( string args , bool redirectStandardOutput ) =>
38
33
new ProcessStartInfo ( dotnet , args )
39
34
{
40
35
UseShellExecute = false ,
41
- RedirectStandardOutput = true
36
+ RedirectStandardOutput = redirectStandardOutput
42
37
} ;
43
38
44
- private bool RunCommandAux ( string args , bool silent )
39
+ private bool RunCommand ( string args )
45
40
{
46
41
progressMonitor . RunningProcess ( $ "{ dotnet } { args } ") ;
47
- using var proc = silent
48
- ? Process . Start ( MakeDotnetStartInfo ( args ) )
49
- : Process . Start ( dotnet , args ) ;
42
+ using var proc = Process . Start ( MakeDotnetStartInfo ( args , redirectStandardOutput : false ) ) ;
50
43
proc ? . WaitForExit ( ) ;
51
44
var exitCode = proc ? . ExitCode ?? - 1 ;
52
45
if ( exitCode != 0 )
@@ -57,12 +50,6 @@ private bool RunCommandAux(string args, bool silent)
57
50
return true ;
58
51
}
59
52
60
- private bool RunCommand ( string args ) =>
61
- RunCommandAux ( args , false ) ;
62
-
63
- private bool RunCommandSilently ( string args ) =>
64
- RunCommandAux ( args , true ) ;
65
-
66
53
public bool RestoreToDirectory ( string projectOrSolutionFile , string packageDirectory , string ? pathToNugetConfig = null )
67
54
{
68
55
var args = $ "restore --no-dependencies \" { projectOrSolutionFile } \" --packages \" { packageDirectory } \" /p:DisableImplicitNuGetFallbackFolder=true";
@@ -90,7 +77,7 @@ public bool AddPackage(string folder, string package)
90
77
private IList < string > GetListed ( string args , string artifact )
91
78
{
92
79
progressMonitor . RunningProcess ( $ "{ dotnet } { args } ") ;
93
- var pi = MakeDotnetStartInfo ( args ) ;
80
+ var pi = MakeDotnetStartInfo ( args , redirectStandardOutput : true ) ;
94
81
var exitCode = pi . ReadOutput ( out var artifacts ) ;
95
82
if ( exitCode != 0 )
96
83
{
@@ -104,7 +91,6 @@ private IList<string> GetListed(string args, string artifact)
104
91
public bool Exec ( string execArgs )
105
92
{
106
93
var args = $ "exec { execArgs } ";
107
- //return RunCommandSilently(args);
108
94
return RunCommand ( args ) ;
109
95
}
110
96
}
0 commit comments