11
11
using System . Diagnostics ;
12
12
using System . IO ;
13
13
using System . Linq ;
14
+ using System . Text ;
14
15
using Cake . Common . IO ;
15
16
using Cake . Common . Tools . ILMerge ;
16
17
using Cake . Core . Diagnostics ;
@@ -41,7 +42,144 @@ public static void ApaxInstall(this BuildContext context, IEnumerable<string> fo
41
42
}
42
43
}
43
44
44
- public static void ApaxClean ( this BuildContext context , ( string folder , string name , bool pack ) lib )
45
+ public static void ApaxInstall ( this BuildContext context , string folder )
46
+ {
47
+ var apaxArguments = "install" ;
48
+
49
+ context . Log . Information ( $ "apax { apaxArguments } started in '{ folder } '") ;
50
+ context . ProcessRunner . Start ( Helpers . GetApaxCommand ( ) , new ProcessSettings ( )
51
+ {
52
+ Arguments = apaxArguments ,
53
+ WorkingDirectory = folder ,
54
+ RedirectStandardOutput = false ,
55
+ RedirectStandardError = false ,
56
+ Silent = false
57
+ } ) . WaitForExit ( ) ;
58
+ context . Log . Information ( $ "apax { apaxArguments } completed successfully in '{ folder } '") ;
59
+ }
60
+ public static void ApaxPlcSim ( this BuildContext context , string folder )
61
+ {
62
+ var apaxArguments = "plcsim" ;
63
+
64
+ context . Log . Information ( $ "apax { apaxArguments } started in '{ folder } '") ;
65
+ context . ProcessRunner . Start ( Helpers . GetApaxCommand ( ) , new ProcessSettings ( )
66
+ {
67
+ Arguments = apaxArguments ,
68
+ WorkingDirectory = folder ,
69
+ RedirectStandardOutput = false ,
70
+ RedirectStandardError = false ,
71
+ Silent = false
72
+ } ) . WaitForExit ( ) ;
73
+ context . Log . Information ( $ "apax { apaxArguments } completed successfully in '{ folder } '") ;
74
+ }
75
+ public static string ApaxHwu ( this BuildContext context , string folder , ref bool summaryResult )
76
+ {
77
+ string retVal = ",NOK" ;
78
+ var apaxArguments = "hwu" ;
79
+
80
+ context . Log . Information ( $ "apax { apaxArguments } started in '{ folder } '") ;
81
+
82
+ var processSettings = new ProcessSettings ( )
83
+ {
84
+ Arguments = apaxArguments ,
85
+ WorkingDirectory = folder ,
86
+ RedirectStandardOutput = true ,
87
+ RedirectStandardError = true ,
88
+ Silent = false
89
+ } ;
90
+
91
+ using ( var process = context . ProcessRunner . Start ( Helpers . GetApaxCommand ( ) , processSettings ) )
92
+ {
93
+ if ( process == null )
94
+ {
95
+ summaryResult = false ;
96
+ throw new Exception ( "Failed to start the process." ) ;
97
+ }
98
+
99
+ process . WaitForExit ( ) ;
100
+
101
+ var standardOutput = process . GetStandardOutput ( ) ;
102
+ var standardError = process . GetStandardError ( ) ;
103
+
104
+
105
+ // Check the exit code and handle result
106
+ if ( process . GetExitCode ( ) == 0 )
107
+ {
108
+ foreach ( string line in standardOutput )
109
+ {
110
+ context . Log . Information ( line ) ;
111
+ }
112
+ context . Log . Information ( $ "apax { apaxArguments } completed successfully in '{ folder } '") ;
113
+ retVal = ",OK" ;
114
+ }
115
+ else
116
+ {
117
+ summaryResult = false ;
118
+ foreach ( string line in standardError )
119
+ {
120
+ context . Log . Error ( line ) ;
121
+ }
122
+ context . Log . Error ( $ "apax { apaxArguments } failed with exit code: { process . GetExitCode ( ) } in '{ folder } '") ;
123
+ context . Log . Error ( $ "Error Output: { standardError } ") ;
124
+ }
125
+ return retVal ;
126
+ }
127
+ }
128
+ public static string ApaxSwfd ( this BuildContext context , string folder , ref bool summaryResult )
129
+ {
130
+ string retVal = ",NOK" ;
131
+ var apaxArguments = "swfd" ;
132
+
133
+ context . Log . Information ( $ "apax { apaxArguments } started in '{ folder } '") ;
134
+
135
+ var processSettings = new ProcessSettings ( )
136
+ {
137
+ Arguments = apaxArguments ,
138
+ WorkingDirectory = folder ,
139
+ RedirectStandardOutput = true ,
140
+ RedirectStandardError = true ,
141
+ Silent = false
142
+ } ;
143
+
144
+ using ( var process = context . ProcessRunner . Start ( Helpers . GetApaxCommand ( ) , processSettings ) )
145
+ {
146
+ if ( process == null )
147
+ {
148
+ summaryResult = false ;
149
+ throw new Exception ( "Failed to start the process." ) ;
150
+ }
151
+
152
+ process . WaitForExit ( ) ;
153
+
154
+ var standardOutput = process . GetStandardOutput ( ) ;
155
+ var standardError = process . GetStandardError ( ) ;
156
+
157
+
158
+ // Check the exit code and handle result
159
+ if ( process . GetExitCode ( ) == 0 )
160
+ {
161
+ foreach ( string line in standardOutput )
162
+ {
163
+ context . Log . Information ( line ) ;
164
+ }
165
+ context . Log . Information ( $ "apax { apaxArguments } completed successfully in '{ folder } '") ;
166
+ retVal = ",OK" ;
167
+ }
168
+ else
169
+ {
170
+ summaryResult = false ;
171
+ foreach ( string line in standardError )
172
+ {
173
+ context . Log . Error ( line ) ;
174
+ }
175
+ context . Log . Error ( $ "apax { apaxArguments } failed with exit code: { process . GetExitCode ( ) } in '{ folder } '") ;
176
+ context . Log . Error ( $ "Error Output: { standardError } ") ;
177
+ }
178
+ return retVal ;
179
+ }
180
+ }
181
+
182
+ public static void ApaxClean ( this BuildContext context , ( string folder , string name , bool pack , bool app_run ) lib )
45
183
{
46
184
foreach ( var folder in context . GetAxFolders ( lib ) )
47
185
{
@@ -85,7 +223,7 @@ public static void ApaxBuild(this BuildContext context, IEnumerable<string> fold
85
223
}
86
224
}
87
225
88
- public static void ApaxUpdate ( this BuildContext context , ( string folder , string name , bool pack ) lib )
226
+ public static void ApaxUpdate ( this BuildContext context , ( string folder , string name , bool pack , bool app_run ) lib )
89
227
{
90
228
foreach ( var folder in context . GetAxFolders ( lib ) )
91
229
{
@@ -110,7 +248,7 @@ public static void ApaxUpdate(this BuildContext context, (string folder, string
110
248
}
111
249
}
112
250
113
- public static void ApaxPack ( this BuildContext context , ( string folder , string name , bool pack ) lib )
251
+ public static void ApaxPack ( this BuildContext context , ( string folder , string name , bool pack , bool app_run ) lib )
114
252
{
115
253
116
254
System . Console . WriteLine ( context . ApaxSignKey ) ;
@@ -128,7 +266,7 @@ public static void ApaxPack(this BuildContext context, (string folder, string na
128
266
}
129
267
130
268
131
- public static void ApaxTest ( this BuildContext context , ( string folder , string name , bool pack ) lib )
269
+ public static void ApaxTest ( this BuildContext context , ( string folder , string name , bool pack , bool app_run ) lib )
132
270
{
133
271
foreach ( var folder in context . GetAxFolders ( lib ) )
134
272
{
@@ -160,7 +298,7 @@ public static void ApaxTest(this BuildContext context, (string folder, string na
160
298
}
161
299
}
162
300
163
- public static void ApaxTestLibrary ( this BuildContext context , ( string folder , string name , bool pack ) lib )
301
+ public static void ApaxTestLibrary ( this BuildContext context , ( string folder , string name , bool pack , bool app_run ) lib )
164
302
{
165
303
foreach ( var folder in context . GetLibraryAxFolders ( lib ) )
166
304
{
@@ -202,22 +340,22 @@ public static void ApaxTestLibrary(this BuildContext context, (string folder, st
202
340
}
203
341
}
204
342
205
- public static void ApaxIxc ( this BuildContext context , IEnumerable < string > folders )
206
- {
207
- foreach ( var folder in folders )
208
- {
209
- context . ProcessRunner . Start ( Helpers . GetDotNetCommand ( ) , new ProcessSettings ( )
210
- {
211
- Arguments = "ixc" ,
212
- WorkingDirectory = folder ,
213
- RedirectStandardOutput = false ,
214
- RedirectStandardError = false ,
215
- Silent = false
216
- } ) . WaitForExit ( ) ;
217
- }
218
- }
219
-
220
- public static void ApaxCopyArtifacts ( this BuildContext context , ( string folder , string name , bool pack ) lib )
343
+ // public static void ApaxIxc(this BuildContext context, IEnumerable<string> folders)
344
+ // {
345
+ // foreach (var folder in folders)
346
+ // {
347
+ // context.ProcessRunner.Start(Helpers.GetDotNetCommand(), new ProcessSettings()
348
+ // {
349
+ // Arguments = "ixc",
350
+ // WorkingDirectory = folder,
351
+ // RedirectStandardOutput = false,
352
+ // RedirectStandardError = false,
353
+ // Silent = false
354
+ // }).WaitForExit();
355
+ // }
356
+ // }
357
+
358
+ public static void ApaxCopyArtifacts ( this BuildContext context , ( string folder , string name , bool pack , bool app_run ) lib )
221
359
{
222
360
if ( lib . pack )
223
361
{
@@ -388,4 +526,34 @@ public static void ApaxCatalogInstall(this BuildContext context, string yamlFile
388
526
}
389
527
}
390
528
}
529
+
530
+ //public static void RunPowershellScript(this BuildContext context, string scriptPath, string arguments)
531
+ //{
532
+ // string workDir = Path.GetFullPath(Path.Combine(scriptPath, ".."));
533
+ // context.Log.Information($"Powershell script {scriptPath} with arguments '{arguments}' started");
534
+ // context.ProcessRunner.Start("powershell.exe", new ProcessSettings()
535
+ // {
536
+ // Arguments = $"-NoProfile -ExecutionPolicy Bypass -File \"{scriptPath}\" {arguments}",
537
+ // WorkingDirectory = workDir,
538
+ // RedirectStandardOutput = false,
539
+ // RedirectStandardError = false,
540
+ // Silent = false
541
+ // }).WaitForExit();
542
+ // context.Log.Information($"Powershell script {scriptPath} with arguments '{arguments}' finished");
543
+ //}
544
+
545
+ //public static void DotnetClean(this BuildContext context, string slnFilePath, string arguments)
546
+ //{
547
+ // string workDir = Path.GetFullPath(Path.Combine(slnFilePath, ".."));
548
+ // context.Log.Information($"Dotne clean command started with solution: {slnFilePath}");
549
+ // context.ProcessRunner.Start(Helpers.GetDotNetCommand(), new ProcessSettings()
550
+ // {
551
+ // Arguments = arguments,
552
+ // WorkingDirectory = workDir,
553
+ // RedirectStandardOutput = false,
554
+ // RedirectStandardError = false,
555
+ // Silent = false
556
+ // }).WaitForExit();
557
+ // context.Log.Information($"Dotne clean command finished with solution: {slnFilePath}");
558
+ //}
391
559
}
0 commit comments