Skip to content

RecursiveDir metadata is lost if glob is expanded through a msbuild task in targets #3121

@rohit21agrawal

Description

@rohit21agrawal

Repro:

s:\work\repro_rohit_target_recursivedir>type test.proj
<Project DefaultTargets="Print">
<Target Name="CollectItems" Returns="@(I)">
  <ItemGroup>
    <Inner Include="$(MSBuildThisFileDirectory)\**\file.txt" />
  </ItemGroup>

  <Message Importance="high"
           Text="Inner: @(Inner), recdir: %(Inner.RecursiveDir)" />

</Target>

<Target Name="GetItemsFromInner">
  <Touch Files="folder\subfolder\file.txt" />
  <MSBuild Projects="$(MSBuildThisFileFullPath)"
           Targets="CollectItems">
    <Output TaskParameter="TargetOutputs"
           ItemName="Outer" />
  </MSBuild>
</Target>

<Target Name="Print" DependsOnTargets="CollectItems">
  <Message Importance="high"
           Text="Outer: @(Outer), recdir: %(Outer.RecursiveDir)" />
</Target>
</Project>
s:\work\repro_rohit_target_recursivedir>msbuild /v:m

The impacted scenario is dotnet.exe pack , which provides an extension to run a target in inner build to pack tfm specific content into a package. Due to this bug, users cannot provide globbing paths and expect pack to construct the target path in the package based on RecursiveDir value.

CC: @rainersigwald

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions