1
1
using System . Diagnostics . CodeAnalysis ;
2
+ using System . Runtime . InteropServices . JavaScript ;
2
3
using System . Text ;
3
4
using System . Text . Json ;
4
5
using System . Text . Json . Nodes ;
5
6
using System . Text . RegularExpressions ;
7
+ using BuildConfigGen . Debugging ;
6
8
7
9
namespace BuildConfigGen
8
10
{
@@ -63,11 +65,12 @@ public record ConfigRecord(string name, string constMappingKey, bool isDefault,
63
65
/// <param name="writeUpdates">Write updates if true, else validate that the output is up-to-date</param>
64
66
/// <param name="allTasks"></param>
65
67
/// <param name="getTaskVersionTable"></param>
66
- static void Main ( string ? task = null , string ? configs = null , int ? currentSprint = null , bool writeUpdates = false , bool allTasks = false , bool getTaskVersionTable = false )
68
+ /// <param name="debugAgentDir">When set to the local pipeline agent directory, this tool will produce tasks in debug mode with the corresponding visual studio launch configurations that can be used to attach to built tasks running on this agent</param>
69
+ static void Main ( string ? task = null , string ? configs = null , int ? currentSprint = null , bool writeUpdates = false , bool allTasks = false , bool getTaskVersionTable = false , string ? debugAgentDir = null )
67
70
{
68
71
try
69
72
{
70
- MainInner ( task , configs , currentSprint , writeUpdates , allTasks , getTaskVersionTable ) ;
73
+ MainInner ( task , configs , currentSprint , writeUpdates , allTasks , getTaskVersionTable , debugAgentDir ) ;
71
74
}
72
75
catch ( Exception e2 )
73
76
{
@@ -85,7 +88,7 @@ static void Main(string? task = null, string? configs = null, int? currentSprint
85
88
}
86
89
}
87
90
88
- private static void MainInner ( string ? task , string ? configs , int ? currentSprint , bool writeUpdates , bool allTasks , bool getTaskVersionTable )
91
+ private static void MainInner ( string ? task , string ? configs , int ? currentSprint , bool writeUpdates , bool allTasks , bool getTaskVersionTable , string ? debugAgentDir )
89
92
{
90
93
if ( allTasks )
91
94
{
@@ -98,11 +101,10 @@ private static void MainInner(string? task, string? configs, int? currentSprint,
98
101
NotNullOrThrow ( configs , "Configs is required" ) ;
99
102
}
100
103
104
+ string currentDir = Environment . CurrentDirectory ;
105
+ string gitRootPath = GitUtil . GetGitRootPath ( currentDir ) ;
101
106
if ( getTaskVersionTable )
102
107
{
103
- string currentDir = Environment . CurrentDirectory ;
104
- string gitRootPath = GitUtil . GetGitRootPath ( currentDir ) ;
105
-
106
108
var tasks = MakeOptionsReader . ReadMakeOptions ( gitRootPath ) ;
107
109
108
110
Console . WriteLine ( "config\t task\t version" ) ;
@@ -120,15 +122,16 @@ private static void MainInner(string? task, string? configs, int? currentSprint,
120
122
return ;
121
123
}
122
124
125
+ IDebugConfigGenerator debugConfGen = string . IsNullOrEmpty ( debugAgentDir )
126
+ ? new NoDebugConfigGenerator ( )
127
+ : new VsCodeLaunchConfigGenerator ( gitRootPath , debugAgentDir ) ;
128
+
123
129
if ( allTasks )
124
130
{
125
- string currentDir = Environment . CurrentDirectory ;
126
- string gitRootPath = GitUtil . GetGitRootPath ( currentDir ) ;
127
-
128
131
var tasks = MakeOptionsReader . ReadMakeOptions ( gitRootPath ) ;
129
132
foreach ( var t in tasks . Values )
130
133
{
131
- MainUpdateTask ( t . Name , string . Join ( '|' , t . Configs ) , writeUpdates , currentSprint ) ;
134
+ MainUpdateTask ( t . Name , string . Join ( '|' , t . Configs ) , writeUpdates , currentSprint , debugConfGen ) ;
132
135
}
133
136
}
134
137
else
@@ -139,10 +142,12 @@ private static void MainInner(string? task, string? configs, int? currentSprint,
139
142
// 3. Ideally default windows exception will occur and errors reported to WER/watson. I'm not sure this is happening, perhaps DragonFruit is handling the exception
140
143
foreach ( var t in task ! . Split ( ',' , '|' ) )
141
144
{
142
- MainUpdateTask ( t , configs ! , writeUpdates , currentSprint ) ;
145
+ MainUpdateTask ( t , configs ! , writeUpdates , currentSprint , debugConfGen ) ;
143
146
}
144
147
}
145
148
149
+ debugConfGen . WriteLaunchConfigurations ( ) ;
150
+
146
151
if ( notSyncronizedDependencies . Count > 0 )
147
152
{
148
153
notSyncronizedDependencies . Insert ( 0 , $ "##vso[task.logissue type=error]There are problems with the dependencies in the buildConfig's package.json files. Please fix the following issues:") ;
@@ -225,7 +230,12 @@ private static void GetVersions(string task, string configsString, out List<(str
225
230
}
226
231
}
227
232
228
- private static void MainUpdateTask ( string task , string configsString , bool writeUpdates , int ? currentSprint )
233
+ private static void MainUpdateTask (
234
+ string task ,
235
+ string configsString ,
236
+ bool writeUpdates ,
237
+ int ? currentSprint ,
238
+ IDebugConfigGenerator debugConfigGen )
229
239
{
230
240
if ( string . IsNullOrEmpty ( task ) )
231
241
{
@@ -265,7 +275,7 @@ private static void MainUpdateTask(string task, string configsString, bool write
265
275
{
266
276
ensureUpdateModeVerifier = new EnsureUpdateModeVerifier ( ! writeUpdates ) ;
267
277
268
- MainUpdateTaskInner ( task , currentSprint , targetConfigs ) ;
278
+ MainUpdateTaskInner ( task , currentSprint , targetConfigs , debugConfigGen ) ;
269
279
270
280
ThrowWithUserFriendlyErrorToRerunWithWriteUpdatesIfVeriferError ( task , skipContentCheck : false ) ;
271
281
}
@@ -309,7 +319,11 @@ private static void ThrowWithUserFriendlyErrorToRerunWithWriteUpdatesIfVeriferEr
309
319
}
310
320
}
311
321
312
- private static void MainUpdateTaskInner ( string task , int ? currentSprint , HashSet < Config . ConfigRecord > targetConfigs )
322
+ private static void MainUpdateTaskInner (
323
+ string task ,
324
+ int ? currentSprint ,
325
+ HashSet < Config . ConfigRecord > targetConfigs ,
326
+ IDebugConfigGenerator debugConfigGen )
313
327
{
314
328
if ( ! currentSprint . HasValue )
315
329
{
@@ -387,7 +401,8 @@ private static void MainUpdateTaskInner(string task, int? currentSprint, HashSet
387
401
EnsureBuildConfigFileOverrides ( config , taskTargetPath ) ;
388
402
}
389
403
390
- var taskConfigExists = File . Exists ( Path . Combine ( taskOutput , "task.json" ) ) ;
404
+ var taskConfigPath = Path . Combine ( taskOutput , "task.json" ) ;
405
+ var taskConfigExists = File . Exists ( taskConfigPath ) ;
391
406
392
407
// only update task output if a new version was added, the config exists, or the task contains preprocessor instructions
393
408
// Note: CheckTaskInputContainsPreprocessorInstructions is expensive, so only call if needed
@@ -423,6 +438,9 @@ private static void MainUpdateTaskInner(string task, int? currentSprint, HashSet
423
438
Path . Combine ( taskTargetPath , buildConfigs , configTaskPath , "package.json" ) ) ;
424
439
WriteNodePackageJson ( taskOutput , config . nodePackageVersion , config . shouldUpdateTypescript ) ;
425
440
}
441
+
442
+ debugConfigGen . WriteTypescriptConfig ( taskOutput ) ;
443
+ debugConfigGen . AddForTask ( taskConfigPath ) ;
426
444
}
427
445
428
446
// delay updating version map file until after buildconfigs generated
0 commit comments