@@ -9,12 +9,14 @@ namespace SmartCode.App.BuildTasks
99{
1010 public class ProcessBuildTask : IBuildTask
1111 {
12+ const string CREATE_NO_WINDOW = "CreateNoWindow" ;
1213 const string WORKING_DIRECTORY = "WorkingDirectory" ;
1314 const string FILE_NAME = "FileName" ;
1415 const string ARGS = "Args" ;
1516 const string TIMEOUT = "Timeout" ;
1617 private readonly ILogger < ProcessBuildTask > _logger ;
1718 const int DEFAULT_TIME_OUT = 30 * 1000 ;
19+ const bool DEFAULT_CREATE_NO_WINDOW = true ;
1820 public bool Initialized => true ;
1921
2022 public string Name => "Process" ;
@@ -35,27 +37,34 @@ public Task Build(BuildContext context)
3537 }
3638 var process = new Process ( ) ;
3739 var startInfo = process . StartInfo ;
38- //startInfo.CreateNoWindow = true;
39- var timeOut = DEFAULT_TIME_OUT ;
40- if ( context . Build . Paramters . TryGetValue ( TIMEOUT , out object timeoutObj ) )
41- {
42- if ( int . TryParse ( timeoutObj . ToString ( ) , out int _timeout ) )
43- {
44- timeOut = _timeout ;
45- }
46- }
40+ startInfo . CreateNoWindow = DEFAULT_CREATE_NO_WINDOW ;
4741 startInfo . FileName = fileNameObj . ToString ( ) ;
4842 startInfo . Arguments = argsObj . ToString ( ) ;
4943 if ( context . Build . Paramters . TryGetValue ( WORKING_DIRECTORY , out object workingDicObj ) )
5044 {
5145 startInfo . WorkingDirectory = workingDicObj . ToString ( ) ;
5246 }
47+ if ( context . Build . Paramters . TryGetValue ( CREATE_NO_WINDOW , out object createNoWinObj ) )
48+ {
49+ if ( bool . TryParse ( createNoWinObj . ToString ( ) , out bool createNoWin ) )
50+ {
51+ startInfo . CreateNoWindow = createNoWin ;
52+ }
53+ }
5354 _logger . LogDebug ( $ "--------Process.FileName:{ startInfo . FileName } ,Args:{ startInfo . Arguments } Start--------") ;
5455 process . ErrorDataReceived += Process_ErrorDataReceived ;
5556 process . OutputDataReceived += Process_OutputDataReceived ;
5657 try
5758 {
5859 process . Start ( ) ;
60+ var timeOut = DEFAULT_TIME_OUT ;
61+ if ( context . Build . Paramters . TryGetValue ( TIMEOUT , out object timeoutObj ) )
62+ {
63+ if ( int . TryParse ( timeoutObj . ToString ( ) , out int _timeout ) )
64+ {
65+ timeOut = _timeout ;
66+ }
67+ }
5968 process . WaitForExit ( timeOut ) ;
6069 _logger . LogDebug ( $ "--------Process.FileName:{ startInfo . FileName } ,Args:{ startInfo . Arguments } End--------") ;
6170 }
0 commit comments