|
62 | 62 | Turn Reference items into a ProjectReference when UseProjectReferences is true.
|
63 | 63 | Order matters. This comes before package resolution because projects should be used when possible instead of packages.
|
64 | 64 | -->
|
65 |
| - <_ProjectReferenceByAssemblyName Condition="'$(UseProjectReferences)' == 'true'" |
| 65 | + <_ProjectReferenceByAssemblyName Condition=" $(UseProjectReferences) " |
66 | 66 | Include="@(ProjectReferenceProvider)"
|
67 | 67 | Exclude="@(_UnusedProjectReferenceProvider)" />
|
68 | 68 |
|
|
148 | 148 | Text="Could not resolve this reference. Could not locate the package or project for "%(Reference.Identity)"" />
|
149 | 149 | </Target>
|
150 | 150 |
|
| 151 | + <!-- |
| 152 | + Remove @(ResolvedCompileFileDefinitions) and @(RuntimeCopyLocalItems) items for patched assemblies between item |
| 153 | + generation and use. Instead, ensure @(ProjectReference) items include the patched projects. This covers indirect |
| 154 | + references and improves test coverage; @(ProjectReference) items were set correctly for direct references. Changes |
| 155 | + are necessary only in servicing builds, in the release/2.1 branch, and when building non-implementation projects. |
| 156 | +
|
| 157 | + This is imperfect because it covers only indirect references to project reference providers (most C# |
| 158 | + implementation projects) and does not work for legacy samples or other non-.NET SDK projects. |
| 159 | +
|
| 160 | + Note: Project reference providers have matching assembly and project names. %(Filename) matches work :) |
| 161 | + --> |
| 162 | + <Target Name="_TestWithPatchedAssemblies" |
| 163 | + Condition=" $(UseProjectReferences) AND '$(PackagesInPatch)' != '' AND |
| 164 | + (@(ResolvedCompileFileDefinitions->Count()) != 0 OR @(RuntimeCopyLocalItems->Count()) != 0) " |
| 165 | + AfterTargets="ResolvePackageAssets" |
| 166 | + BeforeTargets="AssignProjectConfiguration; |
| 167 | + GenerateBuildDependencyFile; |
| 168 | + GeneratePublishDependencyFile; |
| 169 | + ILLink; |
| 170 | + ResolveLockFileCopyLocalFiles; |
| 171 | + ResolveLockFileReferences" |
| 172 | + DependsOnTargets="ResolvePackageAssets"> |
| 173 | + <!-- Find projects patched in this build that need to be added as references. --> |
| 174 | + <ItemGroup> |
| 175 | + <_ProjectsInPatch Remove="@(_ProjectsInPatch)" /> |
| 176 | + <_ProjectsInPatch Include="@(ProjectReferenceProvider->'%(ProjectPath)')" |
| 177 | + Condition=" $(PackagesInPatch.Contains(' %(ProjectReferenceProvider.Identity);')) " |
| 178 | + KeepMetadata="None" /> |
| 179 | + <!-- dotnet-razorpagegenerator project is unique in overriding its package ID. --> |
| 180 | + <_ProjectsInPatch Include="@(ProjectReferenceProvider->WithMetadataValue('Identity', 'dotnet-razorpagegenerator')->'%(ProjectPath)')" |
| 181 | + Condition=" $(PackagesInPatch.Contains(' RazorPageGenerator;')) " |
| 182 | + KeepMetadata="None" /> |
| 183 | + |
| 184 | + <!-- Ignore unreferenced assemblies and directly-referenced projects. --> |
| 185 | + <_ProjectsToAdd Remove="@(_ProjectsToAdd)" /> |
| 186 | + <!-- Condition uses same Filename metadata when evaluating the other two item groups. --> |
| 187 | + <_ProjectsToAdd Include="@(_ProjectsInPatch)" |
| 188 | + Condition=" '%(Filename)' != '' AND |
| 189 | + ('@(ResolvedCompileFileDefinitions)' != '' OR '@(RuntimeCopyLocalItems)' != '') " |
| 190 | + Exclude="@(ProjectReference)" /> |
| 191 | + </ItemGroup> |
| 192 | + |
| 193 | + <ItemGroup Condition=" @(_ProjectsToAdd->Count()) != 0 "> |
| 194 | + <!-- Add direct project references. --> |
| 195 | + <ProjectReference Include="@(_ProjectsToAdd)" IsImplicitlyDefined="true" /> |
| 196 | + |
| 197 | + <!-- Remove assembly references for newly-direct project references (were from baseline packages). --> |
| 198 | + <ResolvedCompileFileDefinitions Remove="@(ResolvedCompileFileDefinitions)" |
| 199 | + Condition=" '%(Filename)' != '' AND '@(_ProjectsToAdd)' != '' " /> |
| 200 | + <RuntimeCopyLocalItems Remove="@(RuntimeCopyLocalItems)" |
| 201 | + Condition=" '%(Filename)' != '' AND '@(_ProjectsToAdd)' != '' " /> |
| 202 | + </ItemGroup> |
| 203 | + </Target> |
| 204 | + |
151 | 205 | <!-- These targets are used to generate the map of assembly name to project files. See also the /t:GenerateProjectList target in build/repo.targets. -->
|
152 | 206 | <Target Name="GetReferencesProvided" Returns="@(ProvidesReference)">
|
153 | 207 | <ItemGroup>
|
|
0 commit comments