Repository navigation
Fix WriteSbaUsageReport crash on project templates in text-only packages - #9987
Merged
Merged
Conversation
ReadSbaPackages recursively enumerated every *.csproj under the SBA package roots and assumed the <id>/<version>/<id>.<version>.csproj layout. The .NET 11 web and McpServer project template text-only packages (added in #9906) contain template .csproj files under content/, which caused an ArgumentOutOfRangeException when slicing the package name. The exception surfaces as warning SBA001 and the sbaPackageUsage.json report is not produced. Only enumerate project files at the <id>/<version> level and validate the naming convention instead of throwing. Co-authored-by: Copilot <[email protected]> Copilot-Session: 1a609b5e-5df1-40ff-8cd7-cbe2e0e3ff01
|
Azure Pipelines: Successfully started running 1 pipeline(s). 1 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The focused change correctly excludes nested template projects while preserving all 147 package-level projects.
Review effort: Balanced
Findings: None
What changed in this PR
Fixes SBA usage report generation for text-only packages containing nested template projects.
Changes:
- Restricts package discovery to
<id>/<version>/. - Validates project filenames before extracting package IDs.
| File | Description |
|---|---|
eng/tools/tasks/Microsoft.DotNet.UnifiedBuild.Tasks/WriteSbaUsageReport.cs |
Safely discovers package-level projects and skips malformed names. |
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
Member
Author
|
@mthalman PTAL. Not sure if that's the right direction. Curious to hear your opinion. Just want to get rid of the build warnings. |
mthalman
approved these changes
Oct 6, 2026
ViktorHofer
enabled auto-merge (squash)
October 6, 2026 13:07
This was referenced Oct 12, 2026
This was referenced Oct 19, 2026
This was referenced Oct 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Since #9906 added the .NET 11 web and McpServer project-template text-only packages, every source-build leg has logged this warning from
eng/finish-source-only.proj:When this happens,
artifacts/log/sbaPackageUsage.jsonis not produced. Example: all 11 SB legs in build 1624624.It shows up as a warning rather than an error because the task call uses
ContinueOnError="WarnAndContinue"andSBA001is listed inMSBuildWarningsNotAsErrors(#4769). That is why it went unnoticed.Root cause
ReadSbaPackagesrecursively enumerated every*.csprojunder the package roots. It then sliced the package name assuming the<id>/<version>/<Id>.<version>.csprojlayout. The new template packages contain template projects undercontent/, which don't follow that layout. Examples:.../microsoft.dotnet.web.projecttemplates.11.0/<ver>/content/.../BlazorWasm.ServiceDefaults1.csproj.../microsoft.mcpserver.projecttemplates.11.0/<ver>/content/McpServer-CSharp/local/McpServer-CSharp.csprojDepending on enumeration order, the task either throws or silently tracks bogus packages.
Fix
<id>/<version>/level..<version>filename suffix. If it doesn't match, logSBA001and continue rather than throwing, so the report is still produced.Validation
I ran the task end to end against the real
src/source-build-assets/srctree onmain:SBA001ArgumentOutOfRangeException(-6)sbaPackageUsage.jsonMicrosoft.DotNet.Web.ProjectTemplates.11.0andMicrosoft.McpServer.ProjectTemplates.11.0tracked correctlyAll 147 package-level projects (118 referencePackages, 9 targetPacks, 20 textOnlyPackages) follow the naming convention. The 15 nested template projects are now skipped.