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
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
TaskEnvironmentandIMultithreadableTask.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:
Proposed Fix