From 9293aab2379d6a122d0cf5ed350356cb23e4d698 Mon Sep 17 00:00:00 2001 From: Viktor Hofer Date: Fri, 11 Feb 2022 08:10:13 +0100 Subject: [PATCH] Subtract instead of building the cartesian product in targets (#65123) * Subtract instead of cartesian product in targets See https://github.com/dotnet/runtime/pull/64000#issuecomment-1030460532. These targets were quite expensive and noticeable in no-op builds. Instead of building the cartesian product via item batching, using subtraction which avoids unnecessary items to be computed. * Update resolveContract.targets * Update targetingpacks.targets * Update resolveContract.targets * Update resolveContract.targets --- eng/references.targets | 12 +++++++----- eng/resolveContract.targets | 10 ++++------ eng/targetingpacks.targets | 14 ++++++++------ 3 files changed, 19 insertions(+), 17 deletions(-) diff --git a/eng/references.targets b/eng/references.targets index 4f57bc14d1e4c..93847dd3944a6 100644 --- a/eng/references.targets +++ b/eng/references.targets @@ -27,11 +27,13 @@ Condition="'$(DisableTransitiveProjectReferences)' != 'true' and '@(DefaultReferenceExclusion)' != ''"> - <_transitiveProjectReferenceWithExclusion Include="@(ProjectReference)"> - %(DefaultReferenceExclusion.Identity) - - + <_transitiveProjectReferenceWithProjectName Include="@(ProjectReference->Metadata('NuGetPackageId'))" + OriginalIdentity="%(Identity)" /> + <_transitiveIncludedProjectReferenceWithProjectName Include="@(_transitiveProjectReferenceWithProjectName)" + Exclude="@(DefaultReferenceExclusion)" /> + <_transitiveExcludedProjectReferenceWithProjectName Include="@(_transitiveProjectReferenceWithProjectName)" + Exclude="@(_transitiveIncludedProjectReferenceWithProjectName)" /> + diff --git a/eng/resolveContract.targets b/eng/resolveContract.targets index cff60b79eb225..327273a100e2d 100644 --- a/eng/resolveContract.targets +++ b/eng/resolveContract.targets @@ -42,12 +42,10 @@ - <_resolvedP2PFiltered Include="@(ProjectReference)"> - $([System.IO.Path]::GetFullPath('%(ProjectReference.Identity)')) - %(ProjectReference.SkipUseReferenceAssembly) - - <_ResolvedProjectReferencePaths Update="@(_resolvedP2PFiltered)" - Condition="'%(_resolvedP2PFiltered.ProjectReferenceItemSpec)' == '%(_resolvedP2PFiltered.MSBuildSourceProjectFile)' and + <_resolvedP2PFiltered Include="@(ProjectReference)" + ProjectReferenceItemSpec="$([System.IO.Path]::GetFullPath('%(ProjectReference.Identity)'))" + SkipUseReferenceAssembly="%(ProjectReference.SkipUseReferenceAssembly)" /> + <_ResolvedProjectReferencePaths Condition="'%(_resolvedP2PFiltered.ProjectReferenceItemSpec)' == '%(_resolvedP2PFiltered.MSBuildSourceProjectFile)' and '%(_resolvedP2PFiltered.SkipUseReferenceAssembly)' == 'true'" ReferenceAssembly="" /> diff --git a/eng/targetingpacks.targets b/eng/targetingpacks.targets index 150ddf7401c9e..33551569c647f 100644 --- a/eng/targetingpacks.targets +++ b/eng/targetingpacks.targets @@ -142,16 +142,18 @@ AfterTargets="ResolveTargetingPackAssets"> <_targetingPackReferenceExclusion Include="$(TargetName)" /> - <_targetingPackReferenceExclusion Include="@(_ResolvedProjectReferencePaths->'%(Filename)')" /> + <_targetingPackReferenceExclusion Include="@(_ResolvedProjectReferencePaths->Metadata('Filename'))" /> <_targetingPackReferenceExclusion Include="@(DefaultReferenceExclusion)" /> - <_targetingPackReferenceWithExclusion Include="@(Reference)"> - %(_targetingPackReferenceExclusion.Identity) - - + <_targetingPackReferenceWithProjectName Include="@(Reference->WithMetadataValue('ExternallyResolved', 'true')->Metadata('Filename'))" + OriginalIdentity="%(Identity)" /> + <_targetingPackIncludedReferenceWithProjectName Include="@(_targetingPackReferenceWithProjectName)" + Exclude="@(_targetingPackReferenceExclusion)" /> + <_targetingPackExcludedReferenceWithProjectName Include="@(_targetingPackReferenceWithProjectName)" + Exclude="@(_targetingPackIncludedReferenceWithProjectName)" /> +