-
-
Notifications
You must be signed in to change notification settings - Fork 200
/
Copy pathStrings.cs
701 lines (600 loc) · 36.2 KB
/
Strings.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
using System;
using System.Globalization;
using System.Text.RegularExpressions;
using Microsoft.Build.Framework;
namespace Microsoft.Build.Logging.StructuredLogger
{
public class Strings
{
private static readonly object locker = new object();
public static StringsSet ResourceSet { get; private set; }
public static void Initialize(string culture = "en-US")
{
if (!StringsSet.ResourcesCollection.ContainsKey(culture))
{
culture = "en-US";
}
lock (locker)
{
if (ResourceSet == null || ResourceSet.Culture != culture)
{
ResourceSet = new StringsSet(culture);
InitializeRegex();
}
}
}
public static string Culture => ResourceSet?.Culture;
public static string GetString(string key)
{
return ResourceSet.GetString(key);
}
public static string Escape(string text) => Regex.Escape(text);
private static void InitializeRegex()
{
OutputPropertyMessagePrefix = GetString("OutputPropertyLogMessage").Replace("{0}={1}", "");
BuildingWithToolsVersionPrefix = CreateRegex(GetString("ToolsVersionInEffectForBuild"), 1);
PropertyGroupMessagePrefix = GetString("PropertyGroupLogMessage").Replace("{0}={1}", "");
ForSearchPathPrefix = CreateRegex(GetString("ResolveAssemblyReference.SearchPath"), 1);
UnifiedPrimaryReferencePrefix = CreateRegex(GetString("ResolveAssemblyReference.UnifiedPrimaryReference"), 1);
PrimaryReferencePrefix = CreateRegex(GetString("ResolveAssemblyReference.PrimaryReference"), 1);
DependencyPrefix = CreateRegex(GetString("ResolveAssemblyReference.Dependency"), 1);
UnifiedDependencyPrefix = CreateRegex(GetString("ResolveAssemblyReference.UnifiedDependency"), 1);
AssemblyFoldersExLocation = CreateRegex(GetString("ResolveAssemblyReference.AssemblyFoldersExSearchLocations"), 1);
AdditionalPropertiesPrefix = CreateRegex(GetString("General.AdditionalProperties"), 1);
OverridingGlobalPropertiesPrefix = CreateRegex(GetString("General.OverridingProperties"), 1);
TargetAlreadyCompleteSuccess = GetString("TargetAlreadyCompleteSuccess");
TargetAlreadyCompleteSuccessRegex = CreateRegex(TargetAlreadyCompleteSuccess, 1);
TargetAlreadyCompleteFailure = GetString("TargetAlreadyCompleteFailure");
TargetAlreadyCompleteFailureRegex = CreateRegex(TargetAlreadyCompleteFailure, 1);
TargetSkippedWhenSkipNonexistentTargets = CreateRegex(GetString("TargetSkippedWhenSkipNonexistentTargets"), 1);
SkipTargetBecauseOutputsUpToDateRegex = CreateRegex(GetString("SkipTargetBecauseOutputsUpToDate"), 1);
RemovingProjectProperties = CreateRegex(GetString("General.ProjectUndefineProperties"), 1);
DuplicateImport = CreateRegex(GetString("DuplicateImport").Replace("{2}", ""), 3);
SearchPathsForMSBuildExtensionsPath = CreateRegex(GetString("SearchPathsForMSBuildExtensionsPath"), 2);
OverridingTarget = CreateRegex(GetString("OverridingTarget"), 4);
TryingExtensionsPath = CreateRegex(GetString("TryingExtensionsPath"), 2);
ProjectImported = GetString("ProjectImported");
string projectImported = GetProjectImportedText();
ProjectImportedRegex = new Regex(projectImported, RegexOptions.Compiled);
TargetSkippedFalseCondition = GetString("TargetSkippedFalseCondition");
TargetSkippedFalseConditionRegex = CreateRegex(TargetSkippedFalseCondition, 3, capture: true);
TaskSkippedFalseCondition = GetString("TaskSkippedFalseCondition");
TaskSkippedFalseConditionRegex = CreateRegex(TaskSkippedFalseCondition, 3, capture: true);
TargetDoesNotExistBeforeTargetMessage = CreateRegex(GetString("TargetDoesNotExistBeforeTargetMessage"), 2);
string copyingFileFromEscaped = Escape(GetString("Copy.FileComment"));
CopyingFileFromRegex = new Regex(copyingFileFromEscaped
.Replace(@"\{0}", @"(?<From>[^\""]+)")
.Replace(@"\{1}", @"(?<To>[^\""]+)"), RegexOptions.Compiled);
CreatingHardLinkRegex = new Regex(Escape(GetString("Copy.HardLinkComment"))
.Replace(@"\{0}", @"(?<From>[^\""]+)")
.Replace(@"\{1}", @"(?<To>[^\""]+)"), RegexOptions.Compiled);
DidNotCopyRegex = new Regex(Escape(GetString("Copy.DidNotCopyBecauseOfFileMatch"))
.Replace(@"\{0}", @"(?<From>[^\""]+)")
.Replace(@"\{1}", @"(?<To>[^\""]+)")
.Replace(@"\{2}", ".*?")
.Replace(@"\{3}", ".*?"), RegexOptions.Compiled);
RobocopyFileCopiedRegex = new Regex(Escape(RobocopyFileCopiedMessage)
.Replace(@"\{0}", @"(?<From>[^\""]+)")
.Replace(@"\{1}", @"(?<To>[^\""]+)"), RegexOptions.Compiled);
RobocopyFileSkippedRegex = new Regex(Escape(RobocopyFileSkippedMessage)
.Replace(@"\{0}", @"(?<From>[^\""]+)")
.Replace(@"\{1}", @"(?<To>[^\""]+)"), RegexOptions.Compiled);
RobocopyFileSkippedAsDuplicateRegex = new Regex(Escape(RobocopyFileSkippedAsDuplicateMessage)
.Replace(@"\{0}", @"(?<From>[^\""]+)")
.Replace(@"\{1}", @"(?<To>[^\""]+)"), RegexOptions.Compiled);
RobocopyFileFailedRegex = new Regex(Escape(RobocopyFileFailedMessage)
.Replace(@"\{0}", @"(?<From>[^\""]+)")
.Replace(@"\{1}", @"(?<To>[^\""]+)"), RegexOptions.Compiled);
ProjectImportSkippedMissingFile = GetString("ProjectImportSkippedMissingFile");
string skippedMissingFile = "^" + ProjectImportSkippedMissingFile
.Replace(".", "\\.")
.Replace("{0}", @"(?<ImportedProject>[^\""]+)")
.Replace("{1}", @"(?<File>[^\""]+)")
.Replace("({2},{3})", @"\((?<Line>\d+),(?<Column>\d+)\)");
ProjectImportSkippedMissingFileRegex = new Regex(skippedMissingFile, RegexOptions.Compiled);
ProjectImportSkippedInvalidFile = GetString("ProjectImportSkippedInvalidFile");
string skippedInvalidFile = "^" + ProjectImportSkippedInvalidFile
.Replace(".", "\\.")
.Replace("{0}", @"(?<ImportedProject>[^\""]+)")
.Replace("{1}", @"(?<File>[^\""]+)")
.Replace("({2},{3})", @"\((?<Line>\d+),(?<Column>\d+)\)");
ProjectImportSkippedInvalidFileRegex = new Regex(skippedInvalidFile, RegexOptions.Compiled);
ProjectImportSkippedEmptyFile = GetString("ProjectImportSkippedEmptyFile");
var skippedEmptyFile = GetSkippedEmptyFileText();
ProjectImportSkippedEmptyFileRegex = new Regex(skippedEmptyFile, RegexOptions.Compiled);
ProjectImportSkippedNoMatches = GetString("ProjectImportSkippedNoMatches");
string skippedNoMatches = GetSkippedNoMatchesText();
ProjectImportSkippedNoMatchesRegex = new Regex(skippedNoMatches, RegexOptions.Compiled);
PropertyReassignment = GetString("PropertyReassignment");
string propertyReassignment = GetPropertyReassignmentText();
PropertyReassignmentRegex = new Regex(propertyReassignment, RegexOptions.Compiled | RegexOptions.Singleline);
// MSBuild 17.6 shipped with this hardcoded to English (the first part of the regex), but it was switched to a different
// localized message in https://github.com/dotnet/msbuild/pull/8665. Support both here.
string deferredResponseFile = ("^(?:Included response file: {0}|" + GetString("PickedUpSwitchesFromAutoResponse") + ")$")
.Replace(@"{0}", @"(?<File>((.:)?[^:\n\r]*?))");
DeferredResponseFileRegex = new Regex(deferredResponseFile, RegexOptions.Compiled | RegexOptions.Singleline);
MetaprojectGenerated = GetString("MetaprojectGenerated");
string messageMetaprojectGeneratedString = MetaprojectGenerated.Replace(@"{0}", @"(?<File>((.:)?[^:\n\r]*?))");
MessageMetaprojectGenerated = new Regex(messageMetaprojectGeneratedString, RegexOptions.Compiled | RegexOptions.Singleline);
TaskFoundFromFactory = GetString("TaskFoundFromFactory");
string taskFoundFromFactory = TaskFoundFromFactory
.Replace(@"""{0}""", @"\""(?<task>.+)\""")
.Replace(@"""{1}""", @"\""(?<assembly>.+)\""");
TaskFoundFromFactoryRegex = new Regex("^" + taskFoundFromFactory, RegexOptions.Compiled);
TaskFound = GetString("TaskFound");
string taskFound = TaskFound
.Replace(@"""{0}""", @"\""(?<task>.+)\""")
.Replace(@"""{1}""", @"\""(?<assembly>.+)\""");
TaskFoundRegex = new Regex("^" + taskFound, RegexOptions.Compiled);
ProjectImportSkippedFalseCondition = GetString("ProjectImportSkippedFalseCondition");
string skippedFalseCondition = GetSkippedFalseConditionText();
ProjectImportSkippedFalseConditionRegex = new Regex(skippedFalseCondition, RegexOptions.Compiled);
CouldNotResolveSdk = GetString("CouldNotResolveSdk");
CouldNotResolveSdkRegex = new Regex("^" + CouldNotResolveSdk
.Replace("{0}", @"(?<Sdk>[^\""]+)"), RegexOptions.Compiled);
ProjectImportSkippedExpressionEvaluatedToEmpty = GetString("ProjectImportSkippedExpressionEvaluatedToEmpty");
string emptyCondition = GetEmptyConditionText();
ProjectImportSkippedExpressionEvaluatedToEmptyRegex = new Regex(emptyCondition, RegexOptions.Compiled);
ConflictReferenceSameSDK = CreateRegex(GetString("GetSDKReferenceFiles.ConflictReferenceSameSDK"), 3);
ConflictRedistDifferentSDK = CreateRegex(GetString("GetSDKReferenceFiles.ConflictRedistDifferentSDK"), 5);
ConflictReferenceDifferentSDK = CreateRegex(GetString("GetSDKReferenceFiles.ConflictRedistDifferentSDK"), 4);
ConflictFoundRegex = new Regex(Escape(GetString("ResolveAssemblyReference.ConflictFound"))
.Replace(@"\{0}", ".*?")
.Replace(@"\{1}", ".*?")
+ ".*", RegexOptions.Compiled);
var foundConflictsRaw = GetString("ResolveAssemblyReference.FoundConflicts");
if (foundConflictsRaw.StartsWith("MSB3277: "))
{
foundConflictsRaw = foundConflictsRaw.Substring("MSB3277: ".Length);
}
var foundConflictsNormalized = foundConflictsRaw.NormalizeLineBreaks();
var foundConflictsEscaped = Escape(foundConflictsNormalized);
FoundConflictsRegex = new Regex(foundConflictsEscaped
.Replace(@"\{0}", @"(?<Assembly>[^\""]*)")
.Replace(@"\{1}", @"(?<Details>.*)"), RegexOptions.Compiled | RegexOptions.Singleline);
TaskParameterMessagePrefix = GetString("TaskParameterPrefix");
OutputItemsMessagePrefix = GetString("OutputItemParameterMessagePrefix");
ItemGroupIncludeMessagePrefix = GetString("ItemGroupIncludeLogMessagePrefix");
ItemGroupRemoveMessagePrefix = GetString("ItemGroupRemoveLogMessage");
GlobalPropertiesPrefix = GetString("General.GlobalProperties");
RemovingPropertiesPrefix = GetString("General.UndefineProperties");
EvaluationStarted = GetString("EvaluationStarted");
EvaluationFinished = GetString("EvaluationFinished");
}
private static string GetEmptyConditionText()
{
if (Culture == "zh-Hans")
{
return "^" + ProjectImportSkippedExpressionEvaluatedToEmpty
.Replace(".", "\\.")
.Replace("{0}", @"(?<ImportedProject>[^\""]+)")
.Replace("{1}", @"(?<File>[^\""]+)")
.Replace("({2}、{3})", @"\((?<Line>\d+)、(?<Column>\d+)\)");
}
return "^" + ProjectImportSkippedExpressionEvaluatedToEmpty
.Replace(".", "\\.")
.Replace("{0}", @"(?<ImportedProject>[^\""]+)")
.Replace("{1}", @"(?<File>[^\""]+)")
.Replace("({2},{3})", @"\((?<Line>\d+),(?<Column>\d+)\)");
}
private static string GetSkippedFalseConditionText()
{
if (Culture == "zh-Hans")
{
return "^" + ProjectImportSkippedFalseCondition
.Replace(".", "\\.")
.Replace("{0}", @"(?<ImportedProject>[^\""]+)")
.Replace("{1}", @"(?<File>[^\""]+)")
.Replace("({2}、{3})", @"\((?<Line>\d+)、(?<Column>\d+)\)")
.Replace("{4}", "(?<Reason>.+)")
.Replace("{5}", "(?<Evaluated>.+)");
}
return "^" + ProjectImportSkippedFalseCondition
.Replace(".", "\\.")
.Replace("{0}", @"(?<ImportedProject>[^\""]+)")
.Replace("{1}", @"(?<File>[^\""]+)")
.Replace("({2},{3})", @"\((?<Line>\d+),(?<Column>\d+)\)")
.Replace("{4}", "(?<Reason>.+)")
.Replace("{5}", "(?<Evaluated>.+)");
}
private static string GetSkippedNoMatchesText()
{
if (Culture == "zh-Hans")
{
return "^" + ProjectImportSkippedNoMatches
.Replace(".", "\\.")
.Replace("{0}", @"(?<ImportedProject>[^\""]+)")
.Replace("{1}", @"(?<File>.*)")
.Replace("({2}、{3})", @"\((?<Line>\d+)、(?<Column>\d+)\)");
}
return "^" + ProjectImportSkippedNoMatches
.Replace(".", "\\.")
.Replace("{0}", @"(?<ImportedProject>[^\""]+)")
.Replace("{1}", @"(?<File>.*)")
.Replace("({2},{3})", @"\((?<Line>\d+),(?<Column>\d+)\)");
}
private static string GetSkippedEmptyFileText()
{
if (Culture == "zh-Hans")
{
return "^" + ProjectImportSkippedEmptyFile
.Replace(".", "\\.")
.Replace("{0}", @"(?<ImportedProject>[^\""]+)")
.Replace("{1}", @"(?<File>[^\""]+)")
.Replace("({2}、{3})", @"\((?<Line>\d+)、(?<Column>\d+)\)");
}
return "^" + ProjectImportSkippedEmptyFile
.Replace(".", "\\.")
.Replace("{0}", @"(?<ImportedProject>[^\""]+)")
.Replace("{1}", @"(?<File>[^\""]+)")
.Replace("({2},{3})", @"\((?<Line>\d+),(?<Column>\d+)\)");
}
private static string GetProjectImportedText()
{
if (Culture == "zh-Hans")
{
return "^" + ProjectImported
.Replace(".", "\\.")
.Replace("{0}", @"(?<ImportedProject>[^\""]+)")
.Replace("{1}", @"(?<File>[^\""]+)")
.Replace("({2}、{3})", @"\((?<Line>\d+)、(?<Column>\d+)\)") + "$";
}
return "^" + ProjectImported
.Replace(".", "\\.")
.Replace("{0}", @"(?<ImportedProject>[^\""]+)")
.Replace("{1}", @"(?<File>[^\""]+)")
.Replace("({2},{3})", @"\((?<Line>\d+),(?<Column>\d+)\)") + "$";
}
private static string GetPropertyReassignmentText()
{
string text = PropertyReassignment;
switch (Culture)
{
case "cs-CZ":
text = text
.Replace(@"$({0})={1} (", @"\$\((?<Name>\w+)\)="".*"" \(")
.Replace(@"{2})", @".*\)")
.Replace("{3}", @"(?<File>.*) \((?<Line>\d+),(?<Column>\d+)\)");
break;
case "ko-KR":
text = text
.Replace(@"$({0})={3}", @"\$\((?<Name>\w+)\)=(?<File>.*) \((?<Line>\d+),(?<Column>\d+)\)")
.Replace("{1}", ".*")
.Replace("{2}", ".*");
break;
case "pl-PL":
text = text
.Replace(@"$({0})=„{1}” (", @"\$\((?<Name>\w+)\)=„.*” \(")
.Replace(@"„{2}”)", @"„.*”\)")
.Replace("{3}", @"(?<File>.*) \((?<Line>\d+),(?<Column>\d+)\)");
break;
case "zh-Hans":
text = text
.Replace(@"$({0})=“{1}”(", @"\$\((?<Name>\w+)\)=“.*”\(")
.Replace(@"{2}”)", @".*”\)")
.Replace("{3}", @"(?<File>.*) \((?<Line>\d+),(?<Column>\d+)\)");
break;
default:
text = text
.Replace(@"$({0})=""{1}"" (", @"\$\((?<Name>\w+)\)="".*"" \(")
.Replace(@"{2}"")", @".*""\)")
.Replace("{3}", @"(?<File>.*) \((?<Line>\d+),(?<Column>\d+)\)");
break;
}
return "^" + text + "$";
}
public static Regex CreateRegex(string text, int replacePlaceholders = 0, RegexOptions options = RegexOptions.Compiled | RegexOptions.Singleline, bool capture = false)
{
if (capture)
{
text = "^" + Regex.Escape(text) + "$";
}
else
{
text = Regex.Escape(text);
}
if (replacePlaceholders > 0)
{
for (int i = 0; i < replacePlaceholders; i++)
{
if (capture)
{
text = text.Replace(@$"\{{{i}}}", $"(?<group{i}>.*?)");
}
else
{
text = text.Replace(@$"\{{{i}}}", $".*?");
}
}
}
var regex = new Regex(text, options);
return regex;
}
public static Regex RemovingProjectProperties { get; set; }
public static Regex DuplicateImport { get; set; }
public static Regex SearchPathsForMSBuildExtensionsPath { get; set; }
public static Regex OverridingTarget { get; set; }
public static Regex TryingExtensionsPath { get; set; }
public static Regex ProjectImportedRegex { get; set; }
public static Regex BuildingWithToolsVersionPrefix { get; set; }
public static Regex ForSearchPathPrefix { get; set; }
public static Regex ProjectImportSkippedMissingFileRegex { get; set; }
public static Regex ProjectImportSkippedInvalidFileRegex { get; set; }
public static Regex ProjectImportSkippedEmptyFileRegex { get; set; }
public static Regex ProjectImportSkippedFalseConditionRegex { get; set; }
public static Regex ProjectImportSkippedExpressionEvaluatedToEmptyRegex { get; set; }
public static Regex ProjectImportSkippedNoMatchesRegex { get; set; }
public static Regex PropertyReassignmentRegex { get; set; }
public static Regex DeferredResponseFileRegex { get; set; }
public static Regex MessageMetaprojectGenerated { get; set; }
public static Regex UnifiedPrimaryReferencePrefix { get; set; }
public static Regex PrimaryReferencePrefix { get; set; }
public static Regex DependencyPrefix { get; set; }
public static Regex UnifiedDependencyPrefix { get; set; }
public static Regex AssemblyFoldersExLocation { get; set; }
public static Regex ConflictReferenceSameSDK { get; set; }
public static Regex ConflictRedistDifferentSDK { get; set; }
/// <summary>
/// "There was a conflict between \"{0}\" and \"{1}\"."
/// </summary>
public static Regex ConflictFoundRegex { get; set; }
/// <summary>
/// "MSB3277: Found conflicts between different versions of \"{0}\" that could not be resolved.\r\n{1}"
/// </summary>
public static Regex FoundConflictsRegex { get; set; }
public static Regex ConflictReferenceDifferentSDK { get; set; }
public static Regex AdditionalPropertiesPrefix { get; set; }
public static Regex OverridingGlobalPropertiesPrefix { get; set; }
public static Regex CopyingFileFromRegex { get; set; }
public static Regex CreatingHardLinkRegex { get; set; }
public static Regex DidNotCopyRegex { get; set; }
public static Regex RobocopyFileCopiedRegex { get; set; }
public static Regex RobocopyFileSkippedRegex { get; set; }
public static Regex RobocopyFileSkippedAsDuplicateRegex { get; set; }
public static Regex RobocopyFileFailedRegex { get; set; }
public static Regex TargetDoesNotExistBeforeTargetMessage { get; set; }
public static Regex TargetAlreadyCompleteSuccessRegex { get; set; }
public static Regex TargetAlreadyCompleteFailureRegex { get; set; }
public static Regex TargetSkippedFalseConditionRegex { get; set; }
public static Regex TaskSkippedFalseConditionRegex { get; set; }
public static Regex TargetSkippedWhenSkipNonexistentTargets { get; set; }
public static Regex SkipTargetBecauseOutputsUpToDateRegex { get; set; }
public static string TaskFoundFromFactory { get; set; }
public static Regex TaskFoundFromFactoryRegex { get; set; }
public static string TaskFound { get; set; }
public static Regex TaskFoundRegex { get; set; }
public static Regex CouldNotResolveSdkRegex { get; set; }
public static string TargetSkippedFalseCondition { get; set; }
public static string TargetAlreadyCompleteSuccess { get; set; }
public static string TargetAlreadyCompleteFailure { get; set; }
public static string ProjectImported { get; set; }
public static string ProjectImportSkippedFalseCondition { get; set; }
public static string CouldNotResolveSdk { get; set; }
public static string ProjectImportSkippedExpressionEvaluatedToEmpty { get; set; }
public static string PropertyReassignment { get; set; }
public static string ProjectImportSkippedNoMatches { get; set; }
public static string ProjectImportSkippedMissingFile { get; set; }
public static string ProjectImportSkippedInvalidFile { get; set; }
public static string ProjectImportSkippedEmptyFile { get; set; }
public static string TaskSkippedFalseCondition { get; set; }
public static string MetaprojectGenerated { get; set; }
public static Match UsingTask(string message, string rawMessage)
{
if (rawMessage == TaskFound &&
TaskFoundRegex.Match(message) is Match found &&
found.Success)
{
return found;
}
if (rawMessage == TaskFoundFromFactory &&
TaskFoundFromFactoryRegex.Match(message) is Match foundFromFactory &&
foundFromFactory.Success)
{
return foundFromFactory;
}
return Match.Empty;
}
public static TargetSkipReason GetTargetSkipReason(string message)
{
// these were emitted as simple messages until binlog version 14
// (see https://github.com/dotnet/msbuild/pull/6402)
if (TargetAlreadyCompleteSuccessRegex.IsMatch(message))
{
return TargetSkipReason.PreviouslyBuiltSuccessfully;
}
if (TargetAlreadyCompleteFailureRegex.IsMatch(message))
{
return TargetSkipReason.PreviouslyBuiltUnsuccessfully;
}
if (SkipTargetBecauseOutputsUpToDateRegex.IsMatch(message))
{
return TargetSkipReason.OutputsUpToDate;
}
//if (TargetSkippedWhenSkipNonexistentTargets.IsMatch(message))
//{
// return TargetSkipReason.TargetDoesNotExist;
//}
// realistically control never reaches here (for binlog versions 4 and newer)
// these were converted from Message to TargetSkipped in binlog version 4
if (TargetSkippedFalseConditionRegex.IsMatch(message))
{
return TargetSkipReason.ConditionWasFalse;
}
//TargetAlreadyCompleteSuccess $:$ Target "{0}" skipped.Previously built successfully.
//TargetSkippedFalseCondition $:$ Target "{0}" skipped, due to false condition; ({1}) was evaluated as ({2}).
//TargetAlreadyCompleteFailure $:$ Target "{0}" skipped.Previously built unsuccessfully.
//TargetSkippedWhenSkipNonexistentTargets"><value>Target "{0}" skipped. The target does not exist in the project and SkipNonexistentTargets is set to true.</value></data>
return TargetSkipReason.None;
}
public static bool IsTargetDoesNotExistAndWillBeSkipped(string message)
{
return TargetDoesNotExistBeforeTargetMessage.IsMatch(message);
}
public static Match ProjectWasNotImportedRegex(string message, out string reason)
{
reason = "";
if (ProjectImportSkippedFalseConditionRegex.Match(message) is Match falseCondition && falseCondition.Success)
{
reason = $"false condition; {falseCondition.Groups["Reason"].Value} was evaluated as {falseCondition.Groups["Evaluated"].Value}.";
return falseCondition;
}
else if (ProjectImportSkippedMissingFileRegex.Match(message) is Match missingFile && missingFile.Success)
{
reason = "the file not existing";
return missingFile;
}
else if (ProjectImportSkippedInvalidFileRegex.Match(message) is Match invalidFile && invalidFile.Success)
{
reason = "the file being invalid";
return invalidFile;
}
else if (ProjectImportSkippedEmptyFileRegex.Match(message) is Match emptyFile && emptyFile.Success)
{
reason = "the file being empty";
return emptyFile;
}
else if (ProjectImportSkippedNoMatchesRegex.Match(message) is Match noMatches && noMatches.Success)
{
reason = "no matching files";
return noMatches;
}
else if (ProjectImportSkippedExpressionEvaluatedToEmptyRegex.Match(message) is Match emptyCondition && emptyCondition.Success)
{
reason = $"the expression evaluating to an empty string";
return emptyCondition;
}
else if (CouldNotResolveSdkRegex.Match(message) is Match noSdk && noSdk.Success)
{
reason = $@"could not resolve SDK {noSdk.Groups["Sdk"].Value}";
return noSdk;
}
return Match.Empty;
//ProjectImportSkippedMissingFile $:$ Project "{0}" was not imported by "{1}" at ({2},{3}), due to the file not existing.
//ProjectImportSkippedInvalidFile $:$ Project "{0}" was not imported by "{1}" at({ 2},{3}), due to the file being invalid.
//ProjectImportSkippedEmptyFile $:$ Project "{0}" was not imported by "{1}" at ({2},{3}), due to the file being empty.
//ProjectImportSkippedFalseCondition $:$ Project "{0}" was not imported by "{1}" at({ 2},{3}), due to false condition; ({4}) was evaluated as ({5}).
//ProjectImportSkippedNoMatches $:$ Project "{0}" was not imported by "{1}" at({ 2},{3}), due to no matching files.
}
public static bool IsThereWasAConflictPrefix(string message)
{
if (ConflictFoundRegex.IsMatch(message))
{
return true;
}
return false;
}
public static Match IsFoundConflicts(string text)
{
return FoundConflictsRegex.Match(text);
}
public static string PropertyGroupMessagePrefix { get; set; }
public static string OutputPropertyMessagePrefix { get; set; }
public static string UsedAssemblySearchPathsLocations => "Used AssemblySearchPaths locations";
public static string UnusedAssemblySearchPathsLocations => "Unused AssemblySearchPaths locations";
public static string UsedLocations => "Used locations";
public static string UnusedLocations = "Unused locations";
public static string TaskParameterMessagePrefix { get; set; }
public static string OutputItemsMessagePrefix { get; set; }
public static string ItemGroupIncludeMessagePrefix { get; set; }
public static string ItemGroupRemoveMessagePrefix { get; set; }
public static string GlobalPropertiesPrefix { get; set; }
public static string RemovingPropertiesPrefix { get; set; }
public static string EvaluationStarted { get; set; }
public static string EvaluationFinished { get; set; }
public static string To => "\" to \"";
public static string ToFile => "\" to file \"";
public static string TotalAnalyzerExecutionTime => "Total analyzer execution time:";
public static string TotalGeneratorExecutionTime => "Total generator execution time:";
/// <summary>
/// https://github.com/NuGet/Home/issues/10383
/// </summary>
public static string RestoreTask_CheckingCompatibilityFor = "Checking compatibility for";
public static string RestoreTask_CheckingCompatibilityOfPackages = "Checking compatibility of packages";
public static string RestoreTask_AcquiringLockForTheInstallation = "Acquiring lock for the installation";
public static string RestoreTask_AcquiredLockForTheInstallation = "Acquired lock for the installation";
public static string RestoreTask_CompletedInstallationOf = "Completed installation of";
public static string RestoreTask_ResolvingConflictsFor = "Resolving conflicts for";
public static string RestoreTask_AllPackagesAndProjectsAreCompatible = "All packages and projects are compatible";
public static string RestoreTask_Committing = "Committing restore";
public static string Evaluation => "Evaluation";
public static string Environment => "Environment";
public static string TruncatedEnvironment => "Starting with MSBuild 17.4, only some environment variables are included in the log: the ones read during the build and the ones prefixed with MSBUILD, DOTNET_ or COMPLUS_.\nDefine MSBUILDLOGALLENVIRONMENTVARIABLES to log all environment variables during the build.";
public static string Imports => "Imports";
public static string DetailedSummary => "Detailed summary";
public static string Parameters => "Parameters";
public static string Results => "Results";
public static string SearchPaths => "SearchPaths";
public static string Assemblies => "Assemblies";
public static string TargetOutputs => "TargetOutputs";
public static string AnalyzerReport => "Analyzer Report";
public static string GeneratorReport => "Generator Report";
public static string Properties => "Properties";
public static string PropertyReassignmentFolder => "Property reassignment";
public static string Global => "Global";
public static string EntryTargets => "Entry targets";
public static string TargetFramework => "TargetFramework";
public static string Platform => "Platform";
public static string Configuration => "Configuration";
public static string TargetFrameworks => "TargetFrameworks";
public static string TargetFrameworkVersion => "TargetFrameworkVersion";
public static string AdditionalProperties => "Additional properties";
public static string OutputItems => "OutputItems";
public static string OutputProperties => "OutputProperties";
public static string Items = "Items";
public static string Statistics = "Statistics";
public static string Folder = "Folder";
public static string Inputs => "Inputs";
public static string Outputs => "Outputs";
public static string Assembly => "Assembly";
public static string CommandLineArguments => "CommandLineArguments";
public static string Item => "Item";
public static string AddItem => "AddItem";
public static string RemoveItem => "RemoveItem";
public static string Metadata => "Metadata";
public static string Property => "Property";
public static string Duration => "Duration";
public static string Note => "Note";
public static string DoubleWrites => "DoubleWrites";
public static string MSBuildVersionPrefix => "MSBuild version = ";
public static string MSBuildExecutablePathPrefix => "MSBuild executable path = ";
public static string Warnings = "Warnings";
public static string NodesReusal = "Reusing node";
public static string NodesManagementNode = "Nodes Management";
public static string NoImportEmptyExpression = "empty expression";
public static string NoImportNoMatches = "no matches";
public static string NoImportMissingFile = "missing file";
public static string NoImportInvalidFile = "invalid file";
public static string Errors = "Errors";
public static string Task = "Task";
// These aren't localized, see https://github.com/microsoft/MSBuildSdks/blob/543e965191417dee65471ee57a6702289847b49b/src/Artifacts/Tasks/Robocopy.cs#L66-L77
private const string RobocopyFileCopiedMessage = "Copied {0} to {1}";
private const string RobocopyFileSkippedMessage = "Skipped copying {0} to {1}";
private const string RobocopyFileSkippedAsDuplicateMessage = "Skipped {0} to {1} as duplicate copy";
private const string RobocopyFileFailedMessage = "Failed to copy {0} to {1}";
public static string GetPropertyName(string message)
{
var dollar = message.IndexOf("$");
return message.Substring(dollar + 2, message.IndexOf("=") - dollar - 3);
}
public static bool IsEvaluationMessage(string message)
{
return SearchPathsForMSBuildExtensionsPath.IsMatch(message)
|| OverridingTarget.IsMatch(message)
|| TryingExtensionsPath.IsMatch(message)
|| ProjectImportedRegex.IsMatch(message)
|| DuplicateImport.IsMatch(message)
|| ProjectImportSkippedEmptyFileRegex.IsMatch(message)
|| ProjectImportSkippedFalseConditionRegex.IsMatch(message)
|| ProjectImportSkippedExpressionEvaluatedToEmptyRegex.IsMatch(message)
|| CouldNotResolveSdkRegex.IsMatch(message)
|| ProjectImportSkippedNoMatchesRegex.IsMatch(message)
|| ProjectImportSkippedMissingFileRegex.IsMatch(message)
|| ProjectImportSkippedInvalidFileRegex.IsMatch(message);
//Project "{0}" was not imported by "{1}" at({ 2},{ 3}), due to the file being empty.
//ProjectImportSkippedFalseCondition $:$ Project "{0}" was not imported by "{1}" at ({2},{3}), due to false condition; ({4}) was evaluated as ({5}).
//ProjectImportSkippedNoMatches $:$ Project "{0}" was not imported by "{1}" at ({2},{3}), due to no matching files.
//ProjectImportSkippedMissingFile $:$ Project "{0}" was not imported by "{1}" at ({2},{3}), due to the file not existing.
//ProjectImportSkippedInvalidFile $:$ Project "{0}" was not imported by "{1}" at ({2},{3}), due to the file being invalid.
}
}
}