msbuild icon indicating copy to clipboard operation
msbuild copied to clipboard

Migrate file I/O tasks to multithreadable task API

Open JanProvaznik opened this issue 1 month ago • 0 comments

This PR migrates several file I/O tasks to use the new multithreadable task API by implementing the \IMultiThreadableTask\ interface and using \TaskEnvironment\ for thread-safe path resolution.

Changes

The following tasks now implement \IMultiThreadableTask\ and use \TaskEnvironment.GetAbsolutePath()\ instead of \Path.GetFullPath():

  • Copy.cs
  • Delete.cs
  • MakeDir.cs
  • RemoveDir.cs
  • Touch.cs

Why

\Path.GetFullPath()\ uses process-global state (current working directory) which is not thread-safe when multiple tasks run in parallel. The \TaskEnvironment.GetAbsolutePath()\ method provides thread-safe path resolution by using the task's execution context.

This enables these tasks to be safely executed in parallel when MSBuild's multithreading is enabled.

JanProvaznik avatar Dec 10 '25 16:12 JanProvaznik