Skip to content

Remove SDK polyfills and retarget to newer MSBuild to enable TaskEnvironment.Fallback #13695

Closed

Description

@AR-May

The current polyfill-based approach for enabling multithreading support in SDK tasks is incorrect and leads to broken behavior in MT mode and in edge cases in multiprocess mode.

Problem
SDK framework tasks currently use polyfilled versions of TaskEnvironment and IMultithreadableTask.

These polyfill types are not the same as the real MSBuild types, so MSBuild does not recognize them
However, the multithreadable attribute is recognized, so tasks are treated as multithreadable.
As a result:

  • Tasks are allowed to run in MT mode without task host
  • But MSBuild cannot inject the correct TaskEnvironment
  • This leads to execution in the wrong environment.
  • And in multi-process mode tasks may fail if they would run in .NET task host

Proposed Fix

  • Remove the polyfill entirely
  • Bump the MSBuild version used to compile SDK tasks
  • Target a version that includes TaskEnvironment.Fallback
  • Update SDK tasks to use the real MSBuild APIs

Activity

  1. added
    Area: TasksIssues impacting the tasks shipped in Microsoft.Build.Tasks.Core.dll.
    on May 5, 2026
  2. jankratochvilcz commented on May 6, 2026

    @jankratochvilcz
    Contributor

    Scope from meeting - bump version of MSBuild and instead of polyfill use the real TaskEnvironment. We also need to bump Mark Paine to give him a heads up.

  3. jankratochvilcz commented on May 7, 2026

    @jankratochvilcz
    Contributor

    Sync discussion: the PR for this is open. A few open questions to resolve before merge:

    1. SDK ↔ MSBuild compliance bump. The SDK ships a data file used by the SDK resolver to enforce a minimum MSBuild version. Bumping this in lockstep with the binary update would force users of the .NET 11 SDK inside Visual Studio onto VS 18.6+. The MSBuild binaries used by the SDK will need to be bumped before .NET 11 GA regardless, so this is a question of timing; we may want to update the binaries now but defer the resolver-floor bump to broaden compatibility during the long-tail task migration.
    2. Resolver vs. tasks decoupling. Today the same package version is consumed by both the resolver and the SDK tasks. Worth confirming whether we want to keep the resolver pinned to the older API while moving tasks to the new one, or bump everything together. The resolver shipped in VS still flows from the 10.x stable release branches, so a unified bump appears safe.
    3. Version-override pattern. The PR currently uses per-project VersionOverride on PackageReference to work around binding-redirect issues. Preference is to update the package references centrally instead; the underlying binding-redirect concern should be addressed at its root.
  4. AR-May commented on May 7, 2026

    @AR-May
    MemberAuthor

    7.5.2026: need approval from sdk team to merge the PR.

  5. AR-May commented on May 13, 2026

    @AR-May
    MemberAuthor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Area: MultithreadedArea: TasksIssues impacting the tasks shipped in Microsoft.Build.Tasks.Core.dll.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions