|
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 | + This is imperfect because it covers only project reference providers i.e. most C# implementation projects. |
| 157 | + --> |
| 158 | + <Target Name="_TestPatchedAssemblies" |
| 159 | + Condition=" $(UseProjectReferences) AND '$(PackagesInPatch)' != '' AND '$(MSBuildProjectName)' != 'TestClient' " |
| 160 | + AfterTargets="ResolvePackageAssets" |
| 161 | + BeforeTargets="AssignProjectConfiguration; |
| 162 | + GenerateBuildDependencyFile; |
| 163 | + GeneratePublishDependencyFile; |
| 164 | + ILLink; |
| 165 | + ResolveLockFileCopyLocalFiles; |
| 166 | + ResolveLockFileReferences" |
| 167 | + DependsOnTargets="ResolvePackageAssets"> |
| 168 | + <!-- Find projects patched in this build. --> |
| 169 | + <ItemGroup> |
| 170 | + <_ProjectsInPatch Include="$(PackagesInPatch)"> |
| 171 | + <ProjectPath>@(ProjectReferenceProvider-> |
| 172 | + WithMetadataValue('Identity', '%(_ProjectsInPatch.Identity)')->'%(ProjectPath)')</ProjectPath> |
| 173 | + <!-- dotnet-razorpagegenerator is unique in overriding its package ID. --> |
| 174 | + <ProjectPath |
| 175 | + Condition=" '%(Identity)' == 'RazorPageGenerator' ">@(ProjectReferenceProvider-> |
| 176 | + WithMetadataValue('Identity', 'dotnet-razorpagegenerator')->'%(ProjectPath)')</ProjectPath> |
| 177 | + </_ProjectsInPatch> |
| 178 | + </ItemGroup> |
| 179 | + <!-- Do not warn when unable to find project; many cases e.g. @aspnet/signalr are only used directly. --> |
| 180 | + <ItemGroup> |
| 181 | + <ProjectReference Include="@(_ProjectsInPatch->'%(ProjectPath)')" |
| 182 | + Exclude="@(ProjectReference)" |
| 183 | + IsImplicitlyDefined="true" /> |
| 184 | + </ItemGroup> |
| 185 | + |
| 186 | + <!-- Find the items that need to be removed. Project reference providers all match assembly and project names. --> |
| 187 | + <JoinItems Left="@(ResolvedCompileFileDefinitions)" |
| 188 | + LeftKey="Filename" |
| 189 | + Right="@(_ProjectsInPatch->'%(ProjectPath)')" |
| 190 | + RightKey="Filename" |
| 191 | + ItemSpecToUse="Left"> |
| 192 | + <Output TaskParameter="JoinResult" ItemName="_ResolvedCompileFileDefinitionsToRemove" /> |
| 193 | + </JoinItems> |
| 194 | + <JoinItems Left="@(RuntimeCopyLocalItems)" |
| 195 | + LeftKey="Filename" |
| 196 | + Right="@(_ProjectsInPatch->'%(ProjectPath)')" |
| 197 | + RightKey="Filename" |
| 198 | + ItemSpecToUse="Left"> |
| 199 | + <Output TaskParameter="JoinResult" ItemName="_RuntimeCopyLocalItemsToRemove" /> |
| 200 | + </JoinItems> |
| 201 | + |
| 202 | + <!-- Perform the actual item removals. --> |
| 203 | + <ItemGroup> |
| 204 | + <ResolvedCompileFileDefinitions Remove="@(_ResolvedCompileFileDefinitionsToRemove)" /> |
| 205 | + <RuntimeCopyLocalItems Remove="@(_RuntimeCopyLocalItemsToRemove)" /> |
| 206 | + </ItemGroup> |
| 207 | + </Target> |
| 208 | + |
151 | 209 | <!-- 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 | 210 | <Target Name="GetReferencesProvided" Returns="@(ProvidesReference)">
|
153 | 211 | <ItemGroup>
|
|
0 commit comments