Skip to content

Commit 076d003

Browse files
committed
Use fewer large item groups
- do not dupe the `@(ProjectReferenceProvider)` item group
1 parent 195e3c1 commit 076d003

File tree

1 file changed

+17
-41
lines changed

1 file changed

+17
-41
lines changed

eng/targets/ResolveReferences.targets

Lines changed: 17 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -86,46 +86,22 @@
8686
</ItemGroup>
8787

8888
<!--
89-
Turn Reference items into a ProjectReference when UseProjectReferences is true. Order matters; this
90-
comes before package resolution because projects should be used when possible instead of packages.
89+
Turn Reference items into a ProjectReference when UseProjectReferences is true. Order matters; this
90+
comes before package resolution because projects should be used when possible instead of packages.
9191
-->
9292
<ItemGroup Condition=" '$(EnableCustomReferenceResolution)' == 'true' AND '$(UseProjectReferences)' == 'true' ">
93-
<!-- Copy then Update / Copy to intersect the ProjectReferenceProvider and Reference item groups. -->
94-
<_AllProjectReference Include="@(ProjectReferenceProvider)" />
95-
96-
<!-- Use only Reference items when project is a reference provider. Simplifies project moves and shortens files. -->
97-
<_AllProjectReference Update="@(ProjectReference->'%(Filename)')" DirectUse="1" />
98-
99-
<_AllProjectReference Update="@(Reference)" Use="1">
100-
<!--
101-
Metadata list is long because (a) Update defaults to copying no metadata and (b) ProjectReference metadata
102-
may include (real) Reference metadata and MSBuild task parameters. Even so, the list below is not exhaustive.
103-
-->
104-
<Aliases>%(Reference.Aliases)</Aliases>
105-
<BuildInParallel>%(Reference.BuildInParallel)</BuildInParallel>
106-
<DoNotHarvest>%(Reference.DoNotHarvest)</DoNotHarvest>
107-
<ExcludeAssets>%(Reference.ExcludeAssets)</ExcludeAssets>
108-
<IncludeAssets>%(Reference.IncludeAssets)</IncludeAssets>
109-
<IsNativeImage>%(Reference.IsNativeImage)</IsNativeImage>
110-
<LinkBase>%(Reference.LinkBase)</LinkBase>
111-
<Name>%(Reference.Name)</Name>
112-
<OutputItemType>%(Reference.OutputItemType)</OutputItemType>
113-
<Package>%(Reference.Package)</Package>
114-
<Private>%(Reference.Private)</Private>
115-
<PrivateAssets>%(Reference.PrivateAssets)</PrivateAssets>
116-
<Project>%(Reference.Project)</Project>
117-
<Properties>%(Reference.Properties)</Properties>
118-
<Publish>%(Reference.Publish)</Publish>
119-
<ReferenceOutputAssembly>%(Reference.ReferenceOutputAssembly)</ReferenceOutputAssembly>
120-
<SetPlatform>%(Reference.SetPlatform)</SetPlatform>
121-
<SkipGetTargetFrameworkProperties>%(Reference.SkipGetTargetFrameworkProperties)</SkipGetTargetFrameworkProperties>
122-
<Targets>%(Reference.Targets)</Targets>
123-
<UndefineProperties>%(Reference.UndefineProperties)</UndefineProperties>
124-
<Watch>%(Reference.Watch)</Watch>
125-
</_AllProjectReference>
126-
127-
<ProjectReference Include="@(_AllProjectReference->WithMetadataValue('Use', '1')->'%(ProjectPath)')" Use="" />
128-
<Reference Remove="@(_AllProjectReference->WithMetadataValue('Use', '1'))" />
93+
<!--
94+
For the _CheckForReferenceBoundaries target, mark project reference providers that _should_ be referenced with
95+
Reference items but weren't. General principle is to use only Reference items when referencing a provider.
96+
This simplifies project moves and shortens files.
97+
-->
98+
<ProjectReferenceProvider Update="@(ProjectReference->'%(Filename)')" DirectUse="1" />
99+
100+
<!-- Find Reference items satisfied using project reference providers. -->
101+
<Reference Update="@(ProjectReferenceProvider)" ProjectPath="%(ProjectReferenceProvider.ProjectPath)" />
102+
103+
<ProjectReference Include="@(Reference->Distinct()->'%(ProjectPath)')" />
104+
<Reference Remove="@(Reference->HasMetadata('ProjectPath'))" />
129105
</ItemGroup>
130106

131107
<!--
@@ -136,11 +112,11 @@
136112
<Target Name="_CheckForReferenceBoundaries" BeforeTargets="CollectPackageReferences;ResolveReferences">
137113
<Error
138114
Condition="@(_InvalidReferenceToNonSharedFxAssembly->Count()) != 0 AND '$(TargetFramework)' == '$(DefaultNetCoreTargetFramework)'"
139-
Text="Cannot reference &quot;%(_InvalidReferenceToNonSharedFxAssembly.Identity)&quot;. This dependency is not in the shared framework. See docs/SharedFramework.md for instructions on how to modify what is in the shared framework." />
115+
Text="Cannot reference &quot;%(Identity)&quot;. This dependency is not in the shared framework. See docs/SharedFramework.md for instructions on how to modify what is in the shared framework." />
140116

141117
<Error
142-
Condition=" '$(EnableCustomReferenceResolution)' == 'true' AND @(_AllProjectReference->WithMetadataValue('DirectUse', '1')->Count()) != 0 "
143-
Text="Cannot reference &quot;%(_AllProjectReference.Identity)&quot; with a ProjectReference item; use a Reference item." />
118+
Condition=" '$(EnableCustomReferenceResolution)' == 'true' AND @(ProjectReferenceProvider->WithMetadataValue('DirectUse', '1')->Count()) != 0 "
119+
Text="Cannot reference &quot;%(Identity)&quot; with a ProjectReference item; use a Reference item." />
144120
</Target>
145121

146122
<Target Name="_WarnAboutRedundantRef" AfterTargets="ResolveFrameworkReferences;ProcessFrameworkReferences">

0 commit comments

Comments
 (0)