Skip to content

Commit

Permalink
Adding filtering for duplicate content files for referencing projects
Browse files Browse the repository at this point in the history
  • Loading branch information
sfoslund committed Nov 15, 2019
1 parent 2f706bc commit a6a6c85
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/Tasks/Microsoft.Common.CurrentVersion.targets
Original file line number Diff line number Diff line change
Expand Up @@ -4449,6 +4449,20 @@ Copyright (C) Microsoft Corporation. All rights reserved.
<Output TaskParameter="TargetOutputs" ItemName="_AllChildProjectItemsWithTargetPath"/>

</MSBuild>

<!-- Filter out dependency items that could overwrite referencer content -->
<CreateItem Include="@(_AllChildProjectItemsWithTargetPath)" AdditionalMetadata="ParentContent=%(ContentWithTargetPath.Identity)">
<Output TaskParameter="Include" ItemName="_FilteredChildProjectItemsWithTargetPath"/>
</CreateItem>
<ItemGroup>
<ParentChildContentDuplicates Include="@(_FilteredChildProjectItemsWithTargetPath)" Condition="'%(_FilteredChildProjectItemsWithTargetPath.TargetPath)'=='%(ParentContent)'" />
<_FilteredChildProjectItemsWithTargetPath Remove="@(ParentChildContentDuplicates)" />
<_FilteredChildProjectItemsWithTargetPath>
<ParentContent></ParentContent> <!-- Remove unnecessary metadata -->
</_FilteredChildProjectItemsWithTargetPath>
<_AllChildProjectItemsWithTargetPath Remove="@(_AllChildProjectItemsWithTargetPath)" />
<_AllChildProjectItemsWithTargetPath Include="@(_FilteredChildProjectItemsWithTargetPath->Distinct())" />
</ItemGroup>

<!-- Target outputs must be full paths because they will be consumed by a different project. -->
<ItemGroup>
Expand All @@ -4459,6 +4473,8 @@ Copyright (C) Microsoft Corporation. All rights reserved.
<!-- Remove items which we will never again use - they just sit around taking up memory otherwise -->
<ItemGroup>
<_AllChildProjectItemsWithTargetPath Remove="@(_AllChildProjectItemsWithTargetPath)"/>
<_FilteredChildProjectItemsWithTargetPath Remove="@(_FilteredChildProjectItemsWithTargetPath)"/>
<ParentChildContentDuplicates Remove="@(ParentChildContentDuplicates)"/>
</ItemGroup>

<!-- Get items from this project last so that they will be copied last. -->
Expand Down

0 comments on commit a6a6c85

Please sign in to comment.