@@ -92,17 +92,7 @@ public static async Task<DotnetMuxerResult> RunAsync(
92
92
93
93
if ( DoNotRetry )
94
94
{
95
- if ( args . StartsWith ( "dotnet " , StringComparison . OrdinalIgnoreCase ) )
96
- {
97
- throw new InvalidOperationException ( "Command should not start with 'dotnet'" ) ;
98
- }
99
-
100
- using var dotnet = new DotnetMuxer ( environmentVariables ) ;
101
- int exitCode = await dotnet . Args ( args , workingDirectory , timeoutInSeconds ) ;
102
-
103
- return exitCode != 0 && failIfReturnValueIsNotZero
104
- ? throw new InvalidOperationException ( $ "Command 'dotnet { args } ' failed.\n \n StandardOutput:\n { dotnet . StandardOutput } \n StandardError:\n { dotnet . StandardError } ")
105
- : new DotnetMuxerResult ( args , exitCode , dotnet . StandardOutput , dotnet . StandardOutputLines , dotnet . StandardError , dotnet . StandardErrorLines ) ;
95
+ return await CallTheMuxer ( args , environmentVariables , workingDirectory , timeoutInSeconds , failIfReturnValueIsNotZero ) ;
106
96
}
107
97
else
108
98
{
@@ -112,17 +102,7 @@ public static async Task<DotnetMuxerResult> RunAsync(
112
102
. WaitAndRetryAsync ( delay )
113
103
. ExecuteAsync ( async ( ) =>
114
104
{
115
- if ( args . StartsWith ( "dotnet " , StringComparison . OrdinalIgnoreCase ) )
116
- {
117
- throw new InvalidOperationException ( "Command should not start with 'dotnet'" ) ;
118
- }
119
-
120
- using var dotnet = new DotnetMuxer ( environmentVariables ) ;
121
- int exitCode = await dotnet . Args ( args , workingDirectory , timeoutInSeconds ) ;
122
-
123
- return exitCode != 0 && failIfReturnValueIsNotZero
124
- ? throw new InvalidOperationException ( $ "Command 'dotnet { args } ' failed.\n \n StandardOutput:\n { dotnet . StandardOutput } \n StandardError:\n { dotnet . StandardError } ")
125
- : new DotnetMuxerResult ( args , exitCode , dotnet . StandardOutput , dotnet . StandardOutputLines , dotnet . StandardError , dotnet . StandardErrorLines ) ;
105
+ return await CallTheMuxer ( args , environmentVariables , workingDirectory , timeoutInSeconds , failIfReturnValueIsNotZero ) ;
126
106
} ) ;
127
107
}
128
108
}
@@ -131,4 +111,19 @@ public static async Task<DotnetMuxerResult> RunAsync(
131
111
s_maxOutstandingCommands_semaphore . Release ( ) ;
132
112
}
133
113
}
114
+
115
+ private static async Task < DotnetMuxerResult > CallTheMuxer ( string args , Dictionary < string , string > environmentVariables , string ? workingDirectory , int timeoutInSeconds , bool failIfReturnValueIsNotZero )
116
+ {
117
+ if ( args . StartsWith ( "dotnet " , StringComparison . OrdinalIgnoreCase ) )
118
+ {
119
+ throw new InvalidOperationException ( "Command should not start with 'dotnet'" ) ;
120
+ }
121
+
122
+ using var dotnet = new DotnetMuxer ( environmentVariables ) ;
123
+ int exitCode = await dotnet . Args ( args , workingDirectory , timeoutInSeconds ) ;
124
+
125
+ return exitCode != 0 && failIfReturnValueIsNotZero
126
+ ? throw new InvalidOperationException ( $ "Command 'dotnet { args } ' failed.\n \n StandardOutput:\n { dotnet . StandardOutput } \n StandardError:\n { dotnet . StandardError } ")
127
+ : new DotnetMuxerResult ( args , exitCode , dotnet . StandardOutput , dotnet . StandardOutputLines , dotnet . StandardError , dotnet . StandardErrorLines ) ;
128
+ }
134
129
}
0 commit comments