|
75 | 75 | <_AllowedExplicitPackageReference Include="FSharp.Core" Condition="'$(MSBuildProjectExtension)' == '.fsproj'" />
|
76 | 76 | <_ExplicitPackageReference Include="@(PackageReference)" Exclude="@(_ImplicitPackageReference);@(_AllowedExplicitPackageReference)" />
|
77 | 77 |
|
78 |
| - <_UnusedProjectReferenceProvider Include="@(ProjectReferenceProvider)" Exclude="@(Reference)" /> |
79 |
| - |
80 | 78 | <_CompilationOnlyReference Condition="'$(TargetFramework)' == 'netstandard2.0'" Include="@(Reference->WithMetadataValue('NuGetPackageId','NETStandard.Library'))" />
|
81 | 79 |
|
82 | 80 | <_InvalidReferenceToNonSharedFxAssembly Condition="'$(IsAspNetCoreApp)' == 'true'"
|
|
87 | 85 | @(ExternalAspNetCoreAppReference);
|
88 | 86 | @(_CompilationOnlyReference);
|
89 | 87 | @(Reference->WithMetadataValue('IsSharedSource', 'true'))" />
|
| 88 | + |
90 | 89 | <_OriginalReferences Include="@(Reference)" />
|
91 |
| - <!-- |
92 |
| - Turn Reference items into a ProjectReference when UseProjectReferences is true. |
93 |
| - Order matters. This comes before package resolution because projects should be used when possible instead of packages. |
94 |
| - --> |
95 |
| - <_ProjectReferenceByAssemblyName Condition="'$(UseProjectReferences)' == 'true'" |
96 |
| - Include="@(ProjectReferenceProvider)" |
97 |
| - Exclude="@(_UnusedProjectReferenceProvider)" /> |
| 90 | + </ItemGroup> |
98 | 91 |
|
99 |
| - <!-- Use ref assembly project paths for ref assembly projects --> |
100 |
| - <ProjectReference Condition="'$(ReferenceImplementationAssemblies)' == 'true'" Include="@(_ProjectReferenceByAssemblyName->'%(ProjectPath)')" > |
101 |
| - <IsReferenceAssembly>false</IsReferenceAssembly> |
102 |
| - </ProjectReference> |
| 92 | + <!-- |
| 93 | + Turn Reference items into a ProjectReference when UseProjectReferences is true. Order matters. This comes before |
| 94 | + package resolution (e.g. ResolveCustomReferences) because projects should be used when possible instead of packages. |
103 | 95 |
|
104 |
| - <ProjectReference Condition="'$(ReferenceReferenceAssemblies)' == 'true'" Include="@(_ProjectReferenceByAssemblyName->'%(RefProjectPath)')" > |
105 |
| - <IsReferenceAssembly>true</IsReferenceAssembly> |
106 |
| - </ProjectReference> |
| 96 | + As .NET SDK changes, watch for problems in this target. The BeforeTargets list is a hack required because the SDK |
| 97 | + generally assumes all @(ProjectReference) items are statically defined. Main problem is reliance on internal |
| 98 | + (therefore fragile) target names. |
| 99 | + --> |
| 100 | + <Target Name="ResolveCustomReferencesToProjects" |
| 101 | + Condition=" '$(TargetFramework)' != '' AND '$(EnableCustomReferenceResolution)' == 'true' AND '$(UseProjectReferences)' == 'true' " |
| 102 | + BeforeTargets="AssignProjectConfiguration;ResolveCustomReferences;_LoadRestoreGraphEntryPoints;_GenerateProjectRestoreGraphPerFramework;_GenerateRestoreProjectPathItemsPerFramework"> |
| 103 | + <JoinItems Left="@(Reference)" Right="@(ProjectReferenceProvider)" LeftMetadata="*" RightMetadata="ProjectPath;RefProjectPath"> |
| 104 | + <Output TaskParameter="JoinResult" ItemName="_ProjectReferenceByAssemblyName" /> |
| 105 | + </JoinItems> |
107 | 106 |
|
108 |
| - <Reference Remove="@(_ProjectReferenceByAssemblyName)" /> |
109 |
| - </ItemGroup> |
| 107 | + <ItemGroup> |
| 108 | + <!-- Use ref assembly project paths for ref assembly projects --> |
| 109 | + <ProjectReference Include="@(_ProjectReferenceByAssemblyName->'%(ProjectPath)')" |
| 110 | + Condition="'$(ReferenceImplementationAssemblies)' == 'true'"> |
| 111 | + <IsReferenceAssembly>false</IsReferenceAssembly> |
| 112 | + <ReferenceOutputAssembly Condition=" '%(_ProjectReferenceByAssemblyName.PrivateAssets)' == 'all' ">false</ReferenceOutputAssembly> |
| 113 | + </ProjectReference> |
| 114 | + |
| 115 | + <ProjectReference Include="@(_ProjectReferenceByAssemblyName->'%(RefProjectPath)')" |
| 116 | + Condition="'$(ReferenceReferenceAssemblies)' == 'true'"> |
| 117 | + <IsReferenceAssembly>true</IsReferenceAssembly> |
| 118 | + <ReferenceOutputAssembly Condition=" '%(_ProjectReferenceByAssemblyName.PrivateAssets)' == 'all' ">false</ReferenceOutputAssembly> |
| 119 | + </ProjectReference> |
| 120 | + |
| 121 | + <Reference Remove="@(_ProjectReferenceByAssemblyName)" /> |
| 122 | + </ItemGroup> |
| 123 | + </Target> |
110 | 124 |
|
111 | 125 | <!--
|
112 | 126 | This target resolves remaining Referene items to Packages, if possible. If not, they are left as Reference items fo the SDK to resolve.
|
|
0 commit comments