Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 30 additions & 9 deletions eng/references.targets
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,39 @@
<_FindDependencies>false</_FindDependencies>
</PropertyGroup>

<!-- If a CoreLib ProjectReference is present, make all P2P assets non transitive. -->
<ItemGroup Condition="'@(ProjectReference)' != '' and
@(ProjectReference->AnyHaveMetadataValue('Identity', '$(CoreLibProject)'))">
<ProjectReference Update="@(ProjectReference)"
PrivateAssets="all" />
</ItemGroup>

<!-- Project references shouldn't be copied to the output for non test apps. -->
<ItemDefinitionGroup Condition="'$(IsTestProject)' != 'true' and '$(IsTestSupportProject)' != 'true' and '$(IsGeneratorProject)' != 'true'">
<ProjectReference>
<Private>false</Private>
</ProjectReference>
</ItemDefinitionGroup>

<ItemGroup Condition="'@(ProjectReference)' != ''">
<ProjectReference Update="@(ProjectReference->WithMetadataValue('Filename', 'System.Private.CoreLib'))">
<!-- Don't flow TargetFramework and Platform to use same inputs and outputs as the CoreLib's build as part of the runtime. -->
<UndefineProperties>$(UndefineProperties);TargetFramework;Platform</UndefineProperties>
<SetConfiguration Condition="'$(RuntimeFlavor)' == 'CoreCLR' and
'$(Configuration)' != '$(CoreCLRConfiguration)'">Configuration=$(CoreCLRConfiguration)</SetConfiguration>
<SetConfiguration Condition="'$(RuntimeFlavor)' == 'Mono' and
'$(Configuration)' != '$(MonoConfiguration)'">Configuration=$(MonoConfiguration)</SetConfiguration>
<Private>false</Private>
</ProjectReference>
<!-- If a CoreLib ProjectReference is present, make all P2P assets non transitive. -->
<ProjectReference Update="@(ProjectReference)"
PrivateAssets="all"
Condition="@(ProjectReference->AnyHaveMetadataValue('Filename', 'System.Private.CoreLib'))" />
</ItemGroup>

<!-- Disable TargetArchitectureMismatch warning when we reference CoreLib as it is platform specific. -->
<Target Name="DisableProjectReferenceArchitectureMismatchWarningForCoreLib"
Condition="'@(ProjectReference)' != '' and
@(ProjectReference->AnyHaveMetadataValue('Filename', 'System.Private.CoreLib'))"
BeforeTargets="ResolveAssemblyReferences">
<PropertyGroup>
<ResolveAssemblyWarnOrErrorOnTargetArchitectureMismatch>None</ResolveAssemblyWarnOrErrorOnTargetArchitectureMismatch>
</PropertyGroup>
</Target>

<!-- Filter out transitive P2Ps which should be excluded. -->
<Target Name="FilterTransitiveProjectReferences"
AfterTargets="IncludeTransitiveProjectReferences"
Expand Down Expand Up @@ -55,8 +74,10 @@
</TargetPathWithTargetPlatformMoniker>
</ItemDefinitionGroup>

<Target Name="ValidateReferenceAssemblyProjectReferences" Condition="'$(IsReferenceAssembly)' == 'true'" AfterTargets="ResolveReferences">
<Error Condition="'%(ReferencePath.ReferenceSourceTarget)' == 'ProjectReference' AND '%(ReferencePath.IsReferenceAssembly)' != 'true' AND '%(ReferencePath.ReferenceAssembly)' == ''"
<Target Name="ValidateReferenceAssemblyProjectReferences"
AfterTargets="ResolveReferences"
Condition="'$(IsReferenceAssembly)' == 'true'">
<Error Condition="'%(ReferencePath.ReferenceSourceTarget)' == 'ProjectReference' and '%(ReferencePath.IsReferenceAssembly)' != 'true' and '%(ReferencePath.ReferenceAssembly)' == ''"
Comment on lines +77 to +80
Copy link
Member Author

@ViktorHofer ViktorHofer Feb 10, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just updating the statement to use lowercase "AND" and putting the condition and aftertargets attributes into subsequent lines so that this is easier to read.

Text="Reference assemblies must only reference other reference assemblies and '%(ReferencePath.ProjectReferenceOriginalItemSpec)' is not a reference assembly project and does not set 'ProduceReferenceAssembly'." />
</Target>
</Project>
20 changes: 1 addition & 19 deletions src/libraries/Directory.Build.targets
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project InitialTargets="UpdateProjectReferencesWithAttributes">
<Project>
<PropertyGroup>
<!-- Override strong name key to default to Open for test projects,
Tests which wish to control this should set TestStrongNameKeyId. -->
Expand Down Expand Up @@ -155,24 +155,6 @@

<Import Project="$(RepositoryEngineeringDir)outerBuild.targets" Condition="'$(IsCrossTargetingBuild)' == 'true'" />

<Target Name="UpdateProjectReferencesWithAttributes" Condition="'@(ProjectReference)' != ''">
<ItemGroup>
<ProjectReference Condition="'%(Filename)' == 'System.Private.CoreLib'">
<!-- Don't flow TargetFramework and Platform to use same inputs and outputs as the CoreLib's build as part of the runtime. -->
<UndefineProperties>$(UndefineProperties);TargetFramework;Platform</UndefineProperties>
<SetConfiguration Condition="'$(RuntimeFlavor)' == 'CoreCLR' and
'$(Configuration)' != '$(CoreCLRConfiguration)'">Configuration=$(CoreCLRConfiguration)</SetConfiguration>
<SetConfiguration Condition="'$(RuntimeFlavor)' == 'Mono' and
'$(Configuration)' != '$(MonoConfiguration)'">Configuration=$(MonoConfiguration)</SetConfiguration>
<Private>false</Private>
</ProjectReference>
</ItemGroup>
<!-- Disable TargetArchitectureMismatch warning when we reference CoreLib which is platform specific. -->
<PropertyGroup Condition="@(ProjectReference->AnyHaveMetadataValue('Identity', '$(CoreLibProject)'))">
<ResolveAssemblyWarnOrErrorOnTargetArchitectureMismatch>None</ResolveAssemblyWarnOrErrorOnTargetArchitectureMismatch>
</PropertyGroup>
</Target>

<!--
Do not clean binplace assets in the ref targeting pack to avoid incremental build failures
when the SDK tries to resolve the assets from the FrameworkList.
Expand Down