Skip to content

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

@AR-May

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

Metadata

Metadata

Assignees

No one assigned

    Labels

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

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions