Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions src/Shared/TaskFactoryUtilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -267,5 +267,28 @@ public static bool ShouldCompileForOutOfProcess(IBuildEngine taskFactoryEngineCo

return null;
}

/// <summary>
/// Resolves a potentially relative source code file path for inline task factories.
/// In multithreaded mode (/mt), relative paths are resolved relative to the project file directory
/// rather than the current working directory. In other modes, the path is returned unchanged.
/// </summary>
/// <param name="path">The source code file path to resolve (may be relative or absolute).</param>
/// <param name="isMultiThreadedBuild">Whether the build is running in multithreaded mode.</param>
/// <param name="projectDirectory">The directory of the project file.</param>
/// <returns>The resolved absolute path in multithreaded mode, or the original path otherwise.</returns>
/// <remarks>
/// This method only modifies path resolution in multithreaded builds to maintain
/// backward compatibility with existing multi-process build behavior.
/// </remarks>
public static string ResolveTaskSourceCodePath(string path, bool isMultiThreadedBuild, string projectDirectory)
{
if (!isMultiThreadedBuild || Path.IsPathRooted(path))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any possibility of an error happening if the rooted path is relative and the process for some reason changes its working directory to another disk ?

{
return path;
}

return Path.Combine(projectDirectory, path);
}
}
}
Loading