← Back to Pull requests

Support MSBuild multithreaded builds (-mt) in the MSBuild tasks #4846

Open
unknown opened this pull request with 254 lines diff across 3 files
View on GitHub
unknown unknown commented on Nov 10, 2026 23:53 UTC
Author

MSBuild 18.6 added a multithreaded mode (dotnet build -mt) that runs tasks marked with [MSBuildMultiThreadableTask] inside the build process instead of a separate task host (docs). This PR opts in both MSBuild tasks of the repository.

Changes

  • GeneratePublicApiTask and GenerateEmbeddedConstantsTask are marked with [MSBuildMultiThreadableTask].

  • The attribute is defined internally in common/MSBuildMultiThreadableTaskAttribute.cs (MSBuild matches it by namespace and name only). The packages keep referencing MSBuild 17.14, so they still load in older Visual Studio and SDK versions, which ignore the attribute.

  • In-process tasks no longer run with the project directory as the current directory, so relative paths are now resolved against the project directory:

  • - GeneratePublicApiTask has a new optional ProjectDirectory parameter, passed by both .targets files; the assembly paths and OutputPath are resolved against it.
    - GenerateEmbeddedConstantsTask already had ProjectDirectory; OutputPath is now resolved against it too.
    - Without ProjectDirectory, behavior is unchanged.
  • Docs: a "Multithreaded builds" section in both libraries' pages.
  • Notes for reviewers

  • Both tasks were already thread-safe: no mutable static state, no environment variables, no process start.

  • The SDK in global.json (MSBuild 18.12) enables a strict mode under -mt: the process current directory is a temporary sentinel folder, and files written there are reported as warning MSB4287. The new tests build with -mt -warnAsError:MSB4287 and call each task with relative paths. Without the path fix, the embedded constants task wrote into the sentinel folder, which also confirmed that MSBuild picks up the internal attribute.

  • The new tests need MSBuild 18.6+; they use the SDK from global.json.

  • Tests pass on net10.0 and net11.0 (EmbeddedConstantsGenerator.Tests 16/16, PublicApiGenerator.MSBuild.Tests 11/11).
  • Diff: 254 lines (+190 / -64) across 3 files Reviewer: greptile-apps[bot] Review duration: 18m
    All Vouch review confidence checks passed
    Residual risk 0.22 = Change Risk (0.39) × (1 − Review Confidence (0.43)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.39 · 254 lines diff across 3 files
    0.39
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    42%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Shallow Review Depth shallow_review_depth
    0.344
    Diff Size diff_size
    0.332
    Real PR Conversation Timeline
    1 comments
    "Review active on #4846"
    general weight: 0.35
    Assignees
    Unassigned
    Labels
    risk: low confidence: 43.0% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 39.1% (MEDIUM) · Higher = larger blast radius
    39.1%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 43.0% · Lower = rushed or shallow review
    43.0%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 22.3% · Safe to merge
    22.3%