Track subclasses of MSBuild tasks for telemetry#12623
Merged
YuliiaKovalova merged 5 commits intomainfrom Oct 9, 2025
Merged
Conversation
Contributor
|
Hello @@copilot, I noticed that you’re changing an .swr file or any file under src/Package/MSBuild.VSSetup.. Please make sure to validate this change by an experimental VS insertion. This is accomplished by pushing to an exp/* branch, which requires write permissions to this repo. |
- Extended ProjectTelemetry to track Microsoft task characteristics - Added AddMicrosoftTaskLoaded method to collect task metrics - Track whether tasks are sealed - Track whether tasks inherit from Microsoft.Build.Utilities.Task - Collect telemetry in AssemblyTaskFactory when tasks are instantiated - Added comprehensive unit tests for new functionality Co-authored-by: baronfel <573979+baronfel@users.noreply.github.com>
Co-authored-by: baronfel <573979+baronfel@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Collect telemetry about MSBuild and SDK tasks
Collect telemetry about MSBuild- and SDK-delivered Tasks
Oct 8, 2025
baronfel
requested changes
Oct 8, 2025
…tasks - Renamed event from build/tasks/microsoft to build/tasks/msbuild-subclassed - Changed from counting all Microsoft tasks to tracking non-sealed subclasses - Now stores dictionary mapping Microsoft task names to their subclass usage counts - Only tracks user-authored non-sealed subclasses of Microsoft tasks - Updated all tests to match new behavior Co-authored-by: baronfel <573979+baronfel@users.noreply.github.com>
Copilot
AI
changed the title
Collect telemetry about MSBuild- and SDK-delivered Tasks
Track non-sealed subclasses of MSBuild tasks for telemetry
Oct 8, 2025
baronfel
reviewed
Oct 8, 2025
- Removed the check that excluded sealed tasks from tracking - Now tracks both sealed and non-sealed subclasses of Microsoft tasks - Updated tests to reflect this change - Updated documentation to remove references to non-sealed filtering Co-authored-by: baronfel <573979+baronfel@users.noreply.github.com>
Copilot
AI
changed the title
Track non-sealed subclasses of MSBuild tasks for telemetry
Track subclasses of MSBuild tasks for telemetry
Oct 8, 2025
baronfel
approved these changes
Oct 8, 2025
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR implements telemetry collection to track user-authored subclasses of Microsoft-owned MSBuild tasks. The purpose is to gather data about task inheritance patterns to inform decisions about making tasks sealed, addressing requirements from issue #10855.
Key changes:
- Adds a new telemetry event
build/tasks/msbuild-subclassedthat tracks subclass usage counts - Implements task inheritance hierarchy analysis to identify Microsoft base classes
- Provides comprehensive test coverage for the new telemetry functionality
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/Build/Instance/TaskFactories/AssemblyTaskFactory.cs | Adds Microsoft task detection logic and integrates telemetry tracking into task instantiation |
| src/Build/BackEnd/Components/Logging/ProjectTelemetry.cs | Implements core telemetry collection with inheritance hierarchy walking and data aggregation |
| src/Build.UnitTests/BackEnd/ProjectTelemetry_Tests.cs | Provides comprehensive unit tests covering all telemetry scenarios and edge cases |
YuliiaKovalova
approved these changes
Oct 9, 2025
This was referenced Feb 23, 2026
Merged
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.
Summary
Adds telemetry collection to track user-authored subclasses of Microsoft-owned MSBuild tasks. This data will help inform decisions about making tasks
sealedand other API changes. This addresses the requirements outlined in #10855.Changes
Telemetry Collection
build/tasks/msbuild-subclassedtracks subclasses of Microsoft MSBuild tasksMicrosoft_Build_Utilities_Task: 2indicates 2 user tasks inherit fromMicrosoft.Build.Utilities.TaskImplementation Details
Modified
ProjectTelemetry.cs:TrackTaskSubclassing(Type, bool)method that:Modified
AssemblyTaskFactory.cs:IsMicrosoftAuthoredTask()helper that identifies Microsoft tasks by checking:TrackTaskSubclassing()for every task instantiation inCreateTaskInstance()New test file
ProjectTelemetry_Tests.cs:Example Output
For a build where users have created 2 custom tasks inheriting from
Microsoft.Build.Utilities.Task:If users also subclassed other Microsoft tasks:
Performance Considerations
Extensibility
The implementation walks the entire inheritance hierarchy, making it easy to:
SDK Integration
Follows the existing telemetry pattern where the SDK's
MSBuildLoggeraggregates integer properties across builds and sends them to the telemetry backend. See: https://github.com/dotnet/sdk/blob/main/src/Cli/dotnet/Commands/MSBuild/MSBuildLogger.csTesting
All tests pass:
Fixes #10855
Original prompt
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.