@@ -11,38 +11,61 @@ public static ExecutionResults ExecuteIn(string workingDirectory,
11
11
string exec = null , string execArgs = null , string projectFile = null , string projectArgs = null ,
12
12
bool isTeamCity = false )
13
13
{
14
- var logFile = Path . Combine ( workingDirectory , "log.txt" ) ;
15
- var gitHubFlowVersion = Path . Combine ( PathHelper . GetCurrentDirectory ( ) , "GitVersion.exe" ) ;
16
- var execArg = exec == null ? null : string . Format ( " /exec \" {0}\" " , exec ) ;
17
- var execArgsArg = execArgs == null ? null : string . Format ( " /execArgs \" {0}\" " , execArgs ) ;
18
- var projectFileArg = projectFile == null ? null : string . Format ( " /proj \" {0}\" " , projectFile ) ;
19
- var targetsArg = projectArgs == null ? null : string . Format ( " /projargs \" {0}\" " , projectArgs ) ;
20
- var logArg = string . Format ( " /l \" {0}\" " , logFile ) ;
21
- var arguments = string . Format ( "\" {0}\" {1}{2}{3}{4}{5}" , workingDirectory , execArg , execArgsArg ,
22
- projectFileArg , targetsArg , logArg ) ;
14
+ var args = new ArgumentBuilder ( workingDirectory )
15
+ {
16
+ Exec = exec ,
17
+ ExecArgs = execArgs ,
18
+ ProjectFile = projectFile ,
19
+ ProjectArgs = projectArgs ,
20
+ IsTeamCity = isTeamCity ,
21
+ LogFile = Path . Combine ( workingDirectory , "log.txt" )
22
+ } ;
23
+
24
+ return ExecuteIn ( args ) ;
25
+ }
23
26
27
+ public static ExecutionResults ExecuteIn ( string workingDirectory , string arguments , bool isTeamCity = false )
28
+ {
29
+ var args = new ArgumentBuilder ( workingDirectory )
30
+ {
31
+ AdditionalArguments = arguments ,
32
+ IsTeamCity = isTeamCity ,
33
+ } ;
34
+
35
+ return ExecuteIn ( args ) ;
36
+ }
37
+
38
+ static ExecutionResults ExecuteIn ( ArgumentBuilder arguments )
39
+ {
40
+ var gitHubFlowVersion = Path . Combine ( PathHelper . GetCurrentDirectory ( ) , "GitVersion.exe" ) ;
24
41
var output = new StringBuilder ( ) ;
25
42
26
43
Console . WriteLine ( "Executing: {0} {1}" , gitHubFlowVersion , arguments ) ;
27
44
Console . WriteLine ( ) ;
28
45
var environmentalVariables =
29
46
new [ ]
30
47
{
31
- new KeyValuePair < string , string > ( "TEAMCITY_VERSION" , isTeamCity ? "8.0.0" : null )
48
+ new KeyValuePair < string , string > ( "TEAMCITY_VERSION" , arguments . IsTeamCity ? "8.0.0" : null )
32
49
} ;
33
50
34
51
var exitCode = ProcessHelper . Run (
35
52
s => output . AppendLine ( s ) , s => output . AppendLine ( s ) , null ,
36
- gitHubFlowVersion , arguments , workingDirectory ,
53
+ gitHubFlowVersion , arguments . ToString ( ) , arguments . WorkingDirectory ,
37
54
environmentalVariables ) ;
38
55
39
- var logContents = File . ReadAllText ( logFile ) ;
40
56
Console . WriteLine ( "Output from GitVersion.exe" ) ;
41
57
Console . WriteLine ( "-------------------------------------------------------" ) ;
42
58
Console . WriteLine ( output . ToString ( ) ) ;
43
59
Console . WriteLine ( ) ;
44
60
Console . WriteLine ( ) ;
45
61
Console . WriteLine ( "-------------------------------------------------------" ) ;
62
+
63
+ if ( string . IsNullOrWhiteSpace ( arguments . LogFile ) )
64
+ {
65
+ return new ExecutionResults ( exitCode , output . ToString ( ) , null ) ;
66
+ }
67
+
68
+ var logContents = File . ReadAllText ( arguments . LogFile ) ;
46
69
Console . WriteLine ( "Log from GitVersion.exe" ) ;
47
70
Console . WriteLine ( "-------------------------------------------------------" ) ;
48
71
Console . WriteLine ( logContents ) ;
0 commit comments