@@ -14,8 +14,24 @@ class Program
14
14
15
15
static void Main ( )
16
16
{
17
- int ? exitCode = null ;
17
+ var exitCode = Run ( ) ;
18
18
19
+ if ( Debugger . IsAttached )
20
+ {
21
+ Console . ReadKey ( ) ;
22
+ }
23
+
24
+ if ( exitCode != 0 )
25
+ {
26
+ // Dump log to console if we fail to complete successfully
27
+ Console . Write ( log . ToString ( ) ) ;
28
+ }
29
+
30
+ Environment . Exit ( exitCode ) ;
31
+ }
32
+
33
+ static int Run ( )
34
+ {
19
35
try
20
36
{
21
37
Arguments arguments ;
@@ -29,17 +45,19 @@ static void Main()
29
45
Console . WriteLine ( "Failed to parse arguments: {0}" , string . Join ( " " , argumentsWithoutExeName ) ) ;
30
46
31
47
HelpWriter . Write ( ) ;
32
- return ;
48
+ return 0 ;
33
49
}
34
50
35
51
if ( arguments . IsHelp )
36
52
{
37
53
HelpWriter . Write ( ) ;
38
- return ;
54
+ return 0 ;
39
55
}
40
56
41
57
if ( ! string . IsNullOrEmpty ( arguments . Proj ) || ! string . IsNullOrEmpty ( arguments . Exec ) )
58
+ {
42
59
arguments . Output = OutputType . BuildServer ;
60
+ }
43
61
44
62
ConfigureLogging ( arguments ) ;
45
63
@@ -48,7 +66,7 @@ static void Main()
48
66
if ( string . IsNullOrEmpty ( gitDirectory ) )
49
67
{
50
68
Console . Error . WriteLine ( "Failed to prepare or find the .git directory in path '{0}'" , arguments . TargetPath ) ;
51
- Environment . Exit ( 1 ) ;
69
+ return 1 ;
52
70
}
53
71
54
72
var workingDirectory = Directory . GetParent ( gitDirectory ) . FullName ;
@@ -119,33 +137,16 @@ static void Main()
119
137
{
120
138
var error = string . Format ( "An error occurred:\r \n {0}" , exception . Message ) ;
121
139
Logger . WriteWarning ( error ) ;
122
-
123
- exitCode = 1 ;
140
+ return 1 ;
124
141
}
125
142
catch ( Exception exception )
126
143
{
127
144
var error = string . Format ( "An unexpected error occurred:\r \n {0}" , exception ) ;
128
145
Logger . WriteError ( error ) ;
129
-
130
- exitCode = 1 ;
131
- }
132
-
133
- if ( Debugger . IsAttached )
134
- {
135
- Console . ReadKey ( ) ;
136
- }
137
-
138
- if ( ! exitCode . HasValue )
139
- {
140
- exitCode = 0 ;
141
- }
142
- else
143
- {
144
- // Dump log to console if we fail to complete successfully
145
- Console . Write ( log . ToString ( ) ) ;
146
+ return 1 ;
146
147
}
147
148
148
- Environment . Exit ( exitCode . Value ) ;
149
+ return 0 ;
149
150
}
150
151
151
152
static IEnumerable < IBuildServer > GetApplicableBuildServers ( Authentication authentication )
0 commit comments