Skip to content

[experiment] Add MSBuild binary log detector as replacement for DotNet and NuGet detectors#1710

Open
ericstj wants to merge 26 commits intomicrosoft:mainfrom
ericstj:binlogDetector
Open

[experiment] Add MSBuild binary log detector as replacement for DotNet and NuGet detectors#1710
ericstj wants to merge 26 commits intomicrosoft:mainfrom
ericstj:binlogDetector

Conversation

@ericstj
Copy link
Member

@ericstj ericstj commented Mar 10, 2026

MSBuild logs have much more accurate project information than we can deduce from project build intermediates.

If an MSBuild log is available, we should read it and capture the project information from it, rather than try to deduce that solely from the build artifacts and project.assets.json.

This is still a work in progress.

Copilot AI review requested due to automatic review settings March 10, 2026 21:37
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds an experimental NuGet/.NET detector that can optionally enrich project.assets.json parsing with MSBuild .binlog-extracted project metadata (e.g., test/shipping/dev flags, SDK version), plus an experiment config and accompanying unit/integration tests.

Changes:

  • Introduces MSBuildBinaryLogComponentDetector along with BinLogProcessor, MSBuildProjectInfo, and shared LockFileUtilities.
  • Registers the new detector and an experiment (MSBuildBinaryLogExperiment) in Orchestrator DI.
  • Adds extensive detector and binlog-processing tests; adds MSBuild.StructuredLogger dependency + version pin.

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
test/Microsoft.ComponentDetection.Detectors.Tests/nuget/MSBuildBinaryLogComponentDetectorTests.cs New unit tests covering fallback vs binlog-enhanced behavior and dev-dependency classification rules.
test/Microsoft.ComponentDetection.Detectors.Tests/nuget/BinLogProcessorTests.cs New integration tests that build temp projects to generate/parse .binlog and validate extracted project info.
test/Microsoft.ComponentDetection.Detectors.Tests/Microsoft.ComponentDetection.Detectors.Tests.csproj Adds MSBuild.StructuredLogger test dependency.
src/Microsoft.ComponentDetection.Orchestrator/Extensions/ServiceCollectionExtensions.cs Registers the new experiment config and detector in DI.
src/Microsoft.ComponentDetection.Orchestrator/Experiments/Configs/MSBuildBinaryLogExperiment.cs Defines control vs experiment grouping for telemetry diffing.
src/Microsoft.ComponentDetection.Detectors/nuget/MSBuildProjectInfo.cs New model + merge logic for project metadata and captured items.
src/Microsoft.ComponentDetection.Detectors/nuget/MSBuildBinaryLogComponentDetector.cs New experimental detector that orders binlogs first, indexes project info, then processes assets with overrides.
src/Microsoft.ComponentDetection.Detectors/nuget/LockFileUtilities.cs New shared utilities for NuGet lockfile graph traversal + PackageDownload registration.
src/Microsoft.ComponentDetection.Detectors/nuget/IBinLogProcessor.cs New abstraction for binlog project info extraction (testability).
src/Microsoft.ComponentDetection.Detectors/nuget/BinLogProcessor.cs New binlog parser using StructuredLogger events to populate MSBuildProjectInfo.
src/Microsoft.ComponentDetection.Detectors/Microsoft.ComponentDetection.Detectors.csproj Adds MSBuild.StructuredLogger runtime dependency for detector implementation.
Directory.Packages.props Pins MSBuild.StructuredLogger version.

You can also share your feedback on Copilot code review. Take the survey.

Copilot AI review requested due to automatic review settings March 16, 2026 23:36
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 21 out of 21 changed files in this pull request and generated 4 comments.


You can also share your feedback on Copilot code review. Take the survey.

Copilot AI review requested due to automatic review settings March 17, 2026 03:44
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 21 out of 21 changed files in this pull request and generated 3 comments.


You can also share your feedback on Copilot code review. Take the survey.

Copilot AI review requested due to automatic review settings March 18, 2026 00:52
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 21 out of 21 changed files in this pull request and generated 3 comments.


You can also share your feedback on Copilot code review. Take the survey.

@codecov
Copy link

codecov bot commented Mar 18, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 0.0%. Comparing base (31c5047) to head (e90456b).

Additional details and impacted files
@@     Coverage Diff      @@
##   main   #1710   +/-   ##
============================
============================

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ericstj ericstj requested a review from Copilot March 18, 2026 23:01
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 21 out of 21 changed files in this pull request and generated 2 comments.


You can also share your feedback on Copilot code review. Take the survey.

@ericstj ericstj requested a review from Copilot March 19, 2026 18:09
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 21 out of 21 changed files in this pull request and generated 6 comments.


You can also share your feedback on Copilot code review. Take the survey.

@ericstj ericstj marked this pull request as ready for review March 24, 2026 02:58
@ericstj ericstj requested a review from a team as a code owner March 24, 2026 02:58
@ericstj ericstj requested review from VXianOng and Copilot March 24, 2026 02:58
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 24 out of 24 changed files in this pull request and generated 2 comments.

Comment on lines +311 to +314
catch (Exception ex)
{
this.Logger.LogWarning(ex, "Failed to process binlog file: {BinlogPath}", binlogPath);
}
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The catch-all in ProcessBinlogFile will also swallow OperationCanceledException thrown from ExtractProjectInfo when the scan is cancelled, causing the detector to continue running even though cancellation was requested. Consider explicitly rethrowing OperationCanceledException (or adding a catch filter) when cancellationToken.IsCancellationRequested, and only logging other exceptions.

Copilot uses AI. Check for mistakes.
Comment on lines +471 to +474
catch (Exception ex)
{
this.Logger.LogWarning(ex, "Failed to process NuGet lockfile: {LockFile}", assetsFilePath);
}
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ProcessAssetsFileAsync catches all exceptions and only logs a warning. If cancellation occurs during lockfile processing (e.g., while registering DotNet components in the fallback path), OperationCanceledException will be swallowed and the scan won’t terminate promptly. Prefer rethrowing OperationCanceledException when cancellationToken.IsCancellationRequested and only logging/handling non-cancellation failures.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants