I have a list of projects in my MSBuild file:

<ItemGroup>
    <SubProject Include="**\*.csproj" />
</ItemGroup>

And now, I would like to set, on each project, its TargetPath in a metadata property for each project.

I already know how to extract the target path for each project, and put it on a separate items list:

<Target Name="ExtractTargetPaths">
    <MSBuild Projects="%(SubProject.Identity)" Targets="GetTargetPath">
        <Output TaskParameter="TargetOutputs" ItemName="SubProjectTargetPath" />
    </MSBuild>
</Target>

However, I would like to be able to access that "SubProjectTargetPath" as metadata on the SubProject items instead of having a separate list of items.

That is, instead of writing e.g. this:

<SomeTask Parameter="%(SubProjectTargetPath.Identity)" />

I would be able to write something like:

<SomeTask Parameter="%(SubProject.TargetPath)" />
Edit
Report