You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Design a clean way to work with AbsolutePath and ITaskItem #13820
The multithreaded-task migration introduces AbsolutePath and TaskEnvironment.GetAbsolutePath(string) as the safe way to resolve paths inside tasks. In practice, the vast majority of path-typed task inputs arrive as ITaskItem rather than string, so the current migration pattern is:
AbsolutePath p = TaskEnvironment.GetAbsolutePath(item.ItemSpec);
This has two problems:
Ergonomics. Every task migration repeats the conversion to AbsolutePath. Path-typed outputs going back into ITaskItem are also awkward.
Cross-project correctness. When an item with a relative ItemSpec flows from project A to project B, GetAbsolutePath(item.ItemSpec) re-anchors it to B's directory. The engine-stamped FullPath metadata (anchored to A) might be what the task actually means. See discussion in Migration of GenerateBindingRedirects #13771 (comment).
Goal:
Design a first-class, ergonomic way for tasks to move between ITaskItem and AbsolutePath that is correct in cross-project scenarios, plays well with the analyzer/codefix, and reads naturally at the call site.
Yes, as you correctly pointed out in that comment, Path.GetFullPath(itemFromAnotherProject.ItemSpec) and itemFromAnotherProject.GetProperty("FullPath") can differ--but I think the latter is what folks usually want so I'd like the new API to guide people to something like that. @AlesProkop correctly captured the behavior of the task, but I thought it was a bug at first . . .
When we implement this we should add an analyzer rule to detect use of ItemSpec (at least detecting when itemspec is used in TaskEnvironment.GetAbsolutePath`) and guide users to using other fields, because we think ItemSpec is almost always not what users should use.
FullPath metadata investigation needed — the FullPath metadata is not populated correctly in all cases. The team needs someone to investigate where in the code the incorrect behavior originates (beyond the behavioral observation already documented).
Design options requested — before the design discussion, the team wants documented alternatives for how tasks should work with ITaskItem that may contain relative paths.
Interaction with MT analyzer — this design decision should ideally land before the MT task analyzer is publicly promoted, since the analyzer's guidance on ITaskItem handling depends on the chosen approach. However, it doesn't need to block the initial analyzer publication.
Current workaround — both MSBuild and SDK tasks are currently working around the issue by casting ItemSpec to absolute path on the fly, which is functional but not a clean long-term pattern.
One of the clean ways to interact with this may be to leverage the type-binding in my PRs to remove the need for Task authors to ever consider this question in the first place.
Activity
rainersigwald commentedon May 20, 2026
Yes, as you correctly pointed out in that comment,
Path.GetFullPath(itemFromAnotherProject.ItemSpec)anditemFromAnotherProject.GetProperty("FullPath")can differ--but I think the latter is what folks usually want so I'd like the new API to guide people to something like that. @AlesProkop correctly captured the behavior of the task, but I thought it was a bug at first . . .baronfel commentedon May 20, 2026
When we implement this we should add an analyzer rule to detect use of ItemSpec (at least detecting when itemspec is used in TaskEnvironment.GetAbsolutePath`) and guide users to using other fields, because we think ItemSpec is almost always not what users should use.
.GetMetadata("FullPath")TaskEnvironment.GetAbsolutePath(item)jankratochvilcz commentedon Jun 2, 2026
this will also require some investigation.
jankratochvilcz commentedon Jun 16, 2026
Grooming Discussion (June 2, 2026)
Key points from the grooming session:
FullPathmetadata is not populated correctly in all cases. The team needs someone to investigate where in the code the incorrect behavior originates (beyond the behavioral observation already documented).ITaskItemthat may contain relative paths.ITaskItemhandling depends on the chosen approach. However, it doesn't need to block the initial analyzer publication.ItemSpecto absolute path on the fly, which is functional but not a clean long-term pattern.baronfel commentedon Jun 16, 2026
One of the clean ways to interact with this may be to leverage the type-binding in my PRs to remove the need for Task authors to ever consider this question in the first place.