-
Notifications
You must be signed in to change notification settings - Fork 361
/
Copy pathRuntimeIdentifierInference.BeforeNETSdkTargets.targets
79 lines (65 loc) · 5.44 KB
/
RuntimeIdentifierInference.BeforeNETSdkTargets.targets
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<!-- Licensed to the .NET Foundation under one or more agreements. The .NET Foundation licenses this file to you under the MIT license. -->
<Project>
<PropertyGroup>
<_EnableArcadeRuntimeIdentifierInference Condition="'$(_EnableArcadeRuntimeIdentifierInference)' == ''">$(EnableArcadeRuntimeIdentifierInference)</_EnableArcadeRuntimeIdentifierInference>
<!-- If the user has specified a RID for their project, don't overwrite it. -->
<_EnableArcadeRuntimeIdentifierInference Condition="'$(_EnableArcadeRuntimeIdentifierInference)' == '' and '$(RuntimeIdentifier)' != ''">false</_EnableArcadeRuntimeIdentifierInference>
<!--
If the SDK will infer this project as "RID agnostic", don't infer RIDs.
This should generally match the logic for setting IsRidAgnostic in the SDK.
-->
<_RidAgnosticProject Condition="('$(OutputType)' == 'Library' or '$(IsTestProject)' == 'true') and '$(RuntimeIdentifiers)' == ''">true</_RidAgnosticProject>
<!-- If this project is RID-agnostic, don't infer RIDs. -->
<_EnableArcadeRuntimeIdentifierInference Condition="'$(_EnableArcadeRuntimeIdentifierInference)' == '' and ('$(IsRidAgnostic)' == 'true' or '$(_RidAgnosticProject)' == 'true')">false</_EnableArcadeRuntimeIdentifierInference>
<!--
We only need to infer if the project would use the RID
-->
<_BuildFlavorRequiredRid
Condition="
'$(SelfContained)' == 'true' or
('$(_IsPublishing)' == 'true' and
(
'$(PublishReadyToRun)' == 'true' or
'$(PublishSingleFile)' == 'true' or
'$(PublishAot)' == 'true'
)
)">true</_BuildFlavorRequiredRid>
<_EnableArcadeRuntimeIdentifierInference Condition="'$(_EnableArcadeRuntimeIdentifierInference)' == '' and '$(_BuildFlavorRequiredRid)' != 'true'">false</_EnableArcadeRuntimeIdentifierInference>
<!--
When we're doing a build of a single vertical, we may not have a runtime or host available for any RID outside of our current target.
For many of our projects, we don't actually need to build any RID-specific assets, but the SDK may still try to pull down assets for other RIDs,
in particular for the RID matching the SDK's RID.
To avoid this, we'll default to setting the RID to the vertical's target RID.
To preserve expected behavior for projects that don't specify a RID in a non-vertical build, we won't append the RID to the output path if the user hasn't explicitly requested it.
-->
<_EnableArcadeRuntimeIdentifierInference Condition="'$(_EnableArcadeRuntimeIdentifierInference)' == '' and '$(DotNetBuildTargetRidOnly)' == 'true'">true</_EnableArcadeRuntimeIdentifierInference>
<_EnableArcadeRuntimeIdentifierFilters Condition="'$(EnableArcadeRuntimeIdentifierFilters)' != ''">$(EnableArcadeRuntimeIdentifierFilters)</_EnableArcadeRuntimeIdentifierFilters>
<!--
If we infer a RID for the project, default to filtering down the list of RIDs the project specifies and automatically excluding projects that don't build for this RID.
-->
<_EnableArcadeRuntimeIdentifierFilters Condition="'$(_EnableArcadeRuntimeIdentifierFilters)' == '' and '$(_EnableArcadeRuntimeIdentifierInference)' == 'true'">$(_EnableArcadeRuntimeIdentifierFilters)</_EnableArcadeRuntimeIdentifierFilters>
</PropertyGroup>
<PropertyGroup Condition="'$(_EnableArcadeRuntimeIdentifierInference)' == 'true'">
<!-- If we're inferring a RID, regular builds wouldn't have appended the RID to the output path. Default to not appending to the output path to preserve expected output locations. -->
<AppendRuntimeIdentifierToOutputPath Condition="'$(AppendRuntimeIdentifierToOutputPath)' == ''">false</AppendRuntimeIdentifierToOutputPath>
<RuntimeIdentifier>$(TargetRid)</RuntimeIdentifier>
<!-- If this project would have been inferred as "RID agnostic", preserve that as well. -->
<IsRidAgnostic Condition="'$(_RidAgnosticProject)' == 'true'">true</IsRidAgnostic>
</PropertyGroup>
<PropertyGroup Condition="'$(_EnableArcadeRuntimeIdentifierFilters)' == 'true' and '$(RuntimeIdentifiers)' != ''">
<!-- Prepend and append with semicolons to make the Contains call below simpler. -->
<_ExplicitlySpecifiedRuntimeIdentifiers>;$(RuntimeIdentifiers);</_ExplicitlySpecifiedRuntimeIdentifiers>
<!--
Sometimes we may need to filter the RuntimeIdentifiers list by a RID that is not TargetRid.
Determine which RID to filter on here.
We can't actually use the RID graph here as RID graph filtering is only possible in a task, and we need to do this during property evaluation.
-->
<_FilterRuntimeIdentifier>$(TargetRid)</_FilterRuntimeIdentifier>
<!-- If we're introducing a new runtime identifier with TargetRid, filter instead on BaseOS. -->
<_FilterRuntimeIdentifier Condition="'$(BaseOS)' != ''">$(BaseOS)</_FilterRuntimeIdentifier>
<!-- If a project builds for a set of RIDs specified in the project file and this vertical isn't in the list, suppress building this project. -->
<_SuppressAllTargets Condition="'$(DisableArcadeExcludeFromBuildSupport)' != 'true' and $(_ExplicitlySpecifiedRuntimeIdentifiers).Contains(';$(_FilterRuntimeIdentifier);')) == 'false'">true</_SuppressAllTargets>
<!-- The .NET SDK will try to restore for all specified RIDs. Change the list of RIDs to only our inferred RID to ensure that restore only restores assets that could be available. -->
<RuntimeIdentifiers>$(RuntimeIdentifier)</RuntimeIdentifiers>
</PropertyGroup>
</Project>