Summary
The scheduled source-build-sdk-diff-tests pipeline has been failing daily on refs/heads/main since 2026-04-29. The test Microsoft.DotNet.SourceBuild.Tests.SdkContentTests.CompareMsftToSbTemplatePackageVersions fails on
all 6 source-build legs (SB_AlmaLinux8, SB_Alpine323, SB_CentOSStream10, SB_Fedora43, SB_Ubuntu2404 x64, SB_Ubuntu2404Arm64 arm64) while attempting to parse an MSTest C# template project file as XML.
release/10.0.4xx is unaffected.
Build Information
- Build: internal/2974874 —
source-build-sdk-diff-tests 20260514.2
- Pipeline:
\dotnet\dotnet\source-build-sdk-diff-tests (definition 1231)
- Branch:
refs/heads/main
- Commit:
88f54a26a932b6535047d5ddd4a58370ca356664
- Failing leg:
SB_AlmaLinux8_Offline_MsftSdk_x64 → task Run Tests (and the same task on all 5 other SB legs)
- Recurring since: 2026-04-29 (Build 2963174) — 12+ consecutive scheduled failures on
main
Error Details
[xUnit.net 00:00:55.10] Microsoft.DotNet.SourceBuild.Tests.SdkContentTests.CompareMsftToSbTemplatePackageVersions [FAIL]
[xUnit.net 00:00:55.10] System.Exception : Failed to parse project file 'content/MSTest-CSharp/Company.TestProject1.csproj' from package archive.
[xUnit.net 00:00:55.10] ---- System.Xml.XmlException : The 'Project' start tag on line 2 position 2 does not match the end tag of 'PropertyGroup'. Line 22, position 5.
at Microsoft.DotNet.SourceBuild.Tests.SdkContentTests.GetPackageReferencesFromProjectFile(ZipArchiveEntry entry) in test/Microsoft.DotNet.SourceBuild.Tests/SdkContentTests.cs:line 228
at Microsoft.DotNet.SourceBuild.Tests.SdkContentTests.GetTemplatePackageVersions(...) in SdkContentTests.cs:line 197
at Microsoft.DotNet.SourceBuild.Tests.SdkContentTests.CompareMsftToSbTemplatePackageVersions() in SdkContentTests.cs:line 148
Root Cause
This is a two-factor failure: a latent template bug exposed by a test-hardening change.
Factor 1 — Two 11.0 templates aren't valid standalone XML
Microsoft.DotNet.Common.ProjectTemplates.11.0 (introduced 2025-12-22)
contains two templates whose <!--#if (UseMSTestSdk)--> / <!--#else--> / <!--#endif--> directives wrap structurally unbalanced XML — each branch contains its own <Project> element and </PropertyGroup> close tag:
content/MSTest-CSharp/Company.TestProject1.csproj
content/Playwright-MSTest-CSharp/Company.TestProject1.csproj
The XML parser ignores the #if markers (they look like comments) and sees a single <Project> with one <PropertyGroup> opening and two </PropertyGroup> closes. I verified by parsing every *.csproj under
src/sdk/template_feed/ with .NET's XML parser — only these two fail.
The MSTest-CSharp file is reported in the log because GetPackageReferencesFromProjectFile throws on the first failure; the Playwright variant will be the next failure once MSTest is fixed.
Factor 2 — Test now throws on parse failure (was silent)
dotnet/dotnet#6350 ("Fix EF Core template versions in source-build and add test") added CompareMsftToSbTemplatePackageVersions and changed GetPackageReferencesFromProjectFile to
throw on XmlException instead of returning an empty dictionary:
- catch
+ catch (XmlException ex)
{
- return versions;
+ throw new Exception($"Failed to parse project file '{entry.FullName}' from package archive.", ex);
}
This was an intentional improvement (silent skips would have hidden the very EF Core version drift the PR was trying to detect), but it surfaced the latent template-parse bug the next time the scheduled pipeline ran.
Timeline
| Date (UTC) |
Build |
Branch |
Result |
| 2025-12-22 |
— |
dotnet/sdk |
Broken 11.0 MSTest templates committed (latent — old test silently skipped) |
| 2026-04-28 12:00 |
2962204 |
main |
succeeded (ran before PR #6350 merge at 20:02 UTC) |
| 2026-04-28 20:02 |
— |
main |
PR #6350 merged → test now throws |
| 2026-04-29 12:00 |
2963174 |
main |
first failure |
| 2026-04-29 → present |
(12+ runs) |
main |
all failed with identical error |
| 2026-05-14 12:00 |
2974871 |
release/10.0.4xx |
succeeded (uses ProjectTemplates.10.0, not affected) |
Suggested Fix
Make GetPackageReferencesFromProjectFile tolerant of template-engine directives, since *.csproj files in template-feed nupkgs are template source, not strict XML. Either:
- Preprocess: strip
<!--#if ... -->, <!--#else-->, <!--#endif--> lines before XDocument.Load, or
- Tolerant scan: extract
<PackageReference Include="..." Version="..." /> with a regex-based scan that doesn't require a balanced document.
Both approaches keep the test's coverage on these templates (so version drift in MSTest/Playwright is still caught) while accepting that template source isn't strict XML.
Alternative — fix the templates so each #if branch is independently XML-balanced — would require duplicating large blocks because the two branches use different Project Sdk= values, and is a change in dotnet/sdk (and possibly
dotnet/templating).
Summary
The scheduled
source-build-sdk-diff-testspipeline has been failing daily onrefs/heads/mainsince 2026-04-29. The testMicrosoft.DotNet.SourceBuild.Tests.SdkContentTests.CompareMsftToSbTemplatePackageVersionsfails onall 6 source-build legs (
SB_AlmaLinux8,SB_Alpine323,SB_CentOSStream10,SB_Fedora43,SB_Ubuntu2404x64,SB_Ubuntu2404Arm64arm64) while attempting to parse an MSTest C# template project file as XML.release/10.0.4xxis unaffected.Build Information
source-build-sdk-diff-tests20260514.2\dotnet\dotnet\source-build-sdk-diff-tests(definition 1231)refs/heads/main88f54a26a932b6535047d5ddd4a58370ca356664SB_AlmaLinux8_Offline_MsftSdk_x64→ taskRun Tests(and the same task on all 5 other SB legs)mainError Details
Root Cause
This is a two-factor failure: a latent template bug exposed by a test-hardening change.
Factor 1 — Two 11.0 templates aren't valid standalone XML
Microsoft.DotNet.Common.ProjectTemplates.11.0(introduced 2025-12-22)contains two templates whose
<!--#if (UseMSTestSdk)-->/<!--#else-->/<!--#endif-->directives wrap structurally unbalanced XML — each branch contains its own<Project>element and</PropertyGroup>close tag:content/MSTest-CSharp/Company.TestProject1.csprojcontent/Playwright-MSTest-CSharp/Company.TestProject1.csprojThe XML parser ignores the
#ifmarkers (they look like comments) and sees a single<Project>with one<PropertyGroup>opening and two</PropertyGroup>closes. I verified by parsing every*.csprojundersrc/sdk/template_feed/with .NET's XML parser — only these two fail.The MSTest-CSharp file is reported in the log because
GetPackageReferencesFromProjectFilethrows on the first failure; the Playwright variant will be the next failure once MSTest is fixed.Factor 2 — Test now throws on parse failure (was silent)
dotnet/dotnet#6350 ("Fix EF Core template versions in source-build and add test") added
CompareMsftToSbTemplatePackageVersionsand changedGetPackageReferencesFromProjectFiletothrow on
XmlExceptioninstead of returning an empty dictionary:This was an intentional improvement (silent skips would have hidden the very EF Core version drift the PR was trying to detect), but it surfaced the latent template-parse bug the next time the scheduled pipeline ran.
Timeline
ProjectTemplates.10.0, not affected)Suggested Fix
Make
GetPackageReferencesFromProjectFiletolerant of template-engine directives, since*.csprojfiles in template-feed nupkgs are template source, not strict XML. Either:<!--#if ... -->,<!--#else-->,<!--#endif-->lines beforeXDocument.Load, or<PackageReference Include="..." Version="..." />with a regex-based scan that doesn't require a balanced document.Both approaches keep the test's coverage on these templates (so version drift in MSTest/Playwright is still caught) while accepting that template source isn't strict XML.
Alternative — fix the templates so each
#ifbranch is independently XML-balanced — would require duplicating large blocks because the two branches use differentProject Sdk=values, and is a change indotnet/sdk(and possiblydotnet/templating).