Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,47 @@ internal static partial class SolutionBuildOutput
[GeneratedRegex(@"\berror(\s+[A-Za-z]+\d+)?\s*:", RegexOptions.IgnoreCase)]
private static partial Regex ErrorPattern();

// Older Build SDKs pack an incomplete zip and exit 0 when root components have no source
// files; the only trace is one of these packager lines, printed without any Error: prefix.
[GeneratedRegex(@"^\s*(Following root components are not defined in customizations|Following objects, required by the solution, are not present)", RegexOptions.IgnoreCase)]
private static partial Regex MissingRootComponentsPattern();
// Older Build SDKs pack an incomplete zip and exit 0 when a required component is missing; the
// only trace is this packager line, printed without any Error: prefix. Unlike the root-components
// case below, there is no known false positive for it, so any occurrence is still an error.
[GeneratedRegex(@"^\s*Following objects, required by the solution, are not present", RegexOptions.IgnoreCase)]
private static partial Regex MissingObjectsPattern();

// Same older-SDK trace, but for root components. The header line alone carries no component
// info - it's followed by one "Type='...', Id (or schema name)='...'." line per component,
// matched below - so by itself it's only a hint, not conclusive.
[GeneratedRegex(@"^\s*Following root components are not defined in customizations", RegexOptions.IgnoreCase)]
private static partial Regex MissingRootComponentsHeaderPattern();

// tools-devkit-build#114: SolutionPackagerLib's root-component check reports connectors
// (component type 372, "ECConnector" in its own enum) as missing unconditionally, even when
// correctly packed - the Build SDK's own InvokeSolutionPackager task already independently
// confirms the connector was actually staged before letting such a build succeed, so a genuinely
// missing connector still fails there with a non-zero exit code. It's therefore safe for this
// text scan to stop treating the line as an error for that type specifically.
[GeneratedRegex(@"Type='([^']+)',\s*Id \(or schema name\)='([^']+)'", RegexOptions.IgnoreCase)]
private static partial Regex MissingRootComponentDetailPattern();

private static readonly HashSet<string> KnownFalsePositiveRootComponentTypes =
new(StringComparer.OrdinalIgnoreCase) { "ECConnector" };

[GeneratedRegex(@"\bwarning(\s+[A-Za-z]+\d+)?\s*:", RegexOptions.IgnoreCase)]
private static partial Regex WarningPattern();

internal static BuildOutputSeverity Classify(string line)
{
if (ErrorPattern().IsMatch(line)) return BuildOutputSeverity.Error;
if (MissingRootComponentsPattern().IsMatch(line)) return BuildOutputSeverity.Error;
if (MissingObjectsPattern().IsMatch(line)) return BuildOutputSeverity.Error;

var detail = MissingRootComponentDetailPattern().Match(line);
if (detail.Success)
{
return KnownFalsePositiveRootComponentTypes.Contains(detail.Groups[1].Value)
? BuildOutputSeverity.Warning
: BuildOutputSeverity.Error;
Comment on lines +56 to +58
}

if (MissingRootComponentsHeaderPattern().IsMatch(line)) return BuildOutputSeverity.Warning;
if (WarningPattern().IsMatch(line)) return BuildOutputSeverity.Warning;

return BuildOutputSeverity.Info;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,12 @@ public class SolutionBuildOutputTests
[InlineData(" Error: RootComponent validation failed.", nameof(BuildOutputSeverity.Error))]
[InlineData(@"C:\proj\proj.csproj(4,5): error MSB4018: task failed", nameof(BuildOutputSeverity.Error))]
[InlineData("MSBUILD : error MSB1009: Project file does not exist.", nameof(BuildOutputSeverity.Error))]
[InlineData("Following root components are not defined in customizations:", nameof(BuildOutputSeverity.Error))]
[InlineData("Following root components are not defined in customizations:", nameof(BuildOutputSeverity.Warning))]
[InlineData(" Following objects, required by the solution, are not present. ", nameof(BuildOutputSeverity.Error))]
[InlineData(" Type='Entity', Id (or schema name)='account'.", nameof(BuildOutputSeverity.Error))]
[InlineData(" Type='SystemForm', Id (or schema name)='00000000-0000-0000-0000-000000000001'.", nameof(BuildOutputSeverity.Error))]
[InlineData(" Type='ECConnector', Id (or schema name)='ECConnector-lab_connectorsopenfoodfacts'.", nameof(BuildOutputSeverity.Warning))]
[InlineData(" Type='ecconnector', Id (or schema name)='ECConnector-lab_connectorsopenfoodfacts'.", nameof(BuildOutputSeverity.Warning))]
[InlineData("proj.csproj : warning NU1903: Package has a known vulnerability", nameof(BuildOutputSeverity.Warning))]
[InlineData(" Warning: LocalBranchBuildVersionNumber is null", nameof(BuildOutputSeverity.Warning))]
[InlineData(" 0 Warning(s)", nameof(BuildOutputSeverity.Info))]
Expand Down
Loading