forked from dotnet/runtime
-
Notifications
You must be signed in to change notification settings - Fork 0
/
targetingpacks.targets
157 lines (146 loc) · 10.3 KB
/
targetingpacks.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
<!--
The following properties need to be set for this logic to work correctly:
- ProductVersion
- NetCoreAppCurrent
- NetCoreAppCurrentVersion
- MicrosoftNetCoreAppFrameworkName
- MicrosoftNetCoreAppRefPackDir
- optional: MicrosoftNetCoreAppRuntimePackDir
-->
<Project>
<PropertyGroup>
<LocalFrameworkOverrideName>$(MicrosoftNetCoreAppFrameworkName)</LocalFrameworkOverrideName>
<TargetingpacksTargetsImported>true</TargetingpacksTargetsImported>
</PropertyGroup>
<PropertyGroup Condition="'$(DisableImplicitFrameworkReferences)' != 'true' and
'$(TargetFrameworkIdentifier)' == '.NETCoreApp' and
$([MSBuild]::VersionGreaterThanOrEquals($(TargetFrameworkVersion), '$(NetCoreAppCurrentVersion)'))">
<UseLocalTargetingRuntimePack Condition="'$(UseLocalTargetingRuntimePack)' == ''">true</UseLocalTargetingRuntimePack>
<!-- Tests don't yet use a live build of the apphost: https://github.com/dotnet/runtime/issues/58109. -->
<UseLocalAppHostPack Condition="'$(UseLocalAppHostPack)' == ''">false</UseLocalAppHostPack>
<EnableTargetingPackDownload>false</EnableTargetingPackDownload>
<GenerateErrorForMissingTargetingPacks>false</GenerateErrorForMissingTargetingPacks>
<!-- Hardcode the apphost version until the SDK understands the net7.0 tfm. -->
<_AppHostBaselinePackVersion Condition="'$(UseLocalAppHostPack)' != 'true'">6.0.0-rc.1.21411.2</_AppHostBaselinePackVersion>
</PropertyGroup>
<!-- Add Known* items if the SDK doesn't support the TargetFramework yet. -->
<ItemGroup Condition="'$(UseLocalTargetingRuntimePack)' == 'true'">
<KnownFrameworkReference Include="$(LocalFrameworkOverrideName)"
DefaultRuntimeFrameworkVersion="$(ProductVersion)"
LatestRuntimeFrameworkVersion="$(ProductVersion)"
RuntimeFrameworkName="$(LocalFrameworkOverrideName)"
RuntimePackNamePatterns="$(LocalFrameworkOverrideName).Runtime.**RID**"
RuntimePackRuntimeIdentifiers="linux-arm;linux-arm64;linux-musl-arm64;linux-musl-x64;linux-x64;osx-x64;rhel.6-x64;tizen.4.0.0-armel;tizen.5.0.0-armel;win-arm;win-arm64;win-x64;win-x86;linux-musl-arm;osx-arm64;maccatalyst-x64;maccatalyst-arm64"
TargetFramework="$(NetCoreAppCurrent)"
TargetingPackName="$(LocalFrameworkOverrideName).Ref"
TargetingPackVersion="$(ProductVersion)"
Condition="'@(KnownFrameworkReference)' == '' or !@(KnownFrameworkReference->AnyHaveMetadataValue('TargetFramework', '$(NetCoreAppCurrent)'))" />
<KnownRuntimePack Include="$(LocalFrameworkOverrideName)"
TargetFramework="$(NetCoreAppCurrent)"
RuntimeFrameworkName="$(LocalFrameworkOverrideName)"
LatestRuntimeFrameworkVersion="$(ProductVersion)"
RuntimePackNamePatterns="$(LocalFrameworkOverrideName).Runtime.Mono.**RID**"
RuntimePackRuntimeIdentifiers="linux-arm;linux-arm64;linux-musl-arm64;linux-musl-x64;linux-x64;osx-x64;rhel.6-x64;win-arm;win-arm64;win-x64;win-x86;linux-musl-arm;osx-arm64;maccatalyst-x64;maccatalyst-arm64;browser-wasm;ios-arm64;ios-arm;iossimulator-arm64;iossimulator-x64;iossimulator-x86;tvos-arm64;tvossimulator-arm64;tvossimulator-x64;android-arm64;android-arm;android-x64;android-x86"
RuntimePackLabels="Mono"
Condition="'@(KnownRuntimePack)' == '' or !@(KnownRuntimePack->AnyHaveMetadataValue('TargetFramework', '$(NetCoreAppCurrent)'))"/>
<KnownAppHostPack Include="$(LocalFrameworkOverrideName)"
AppHostPackNamePattern="$(LocalFrameworkOverrideName).Host.**RID**"
AppHostPackVersion="$([MSBuild]::ValueOrDefault('$(_AppHostBaselinePackVersion)', '$(ProductVersion)'))"
AppHostRuntimeIdentifiers="linux-arm;linux-arm64;linux-musl-arm64;linux-musl-x64;linux-x64;osx-x64;rhel.6-x64;tizen.4.0.0-armel;tizen.5.0.0-armel;win-arm;win-arm64;win-x64;win-x86;linux-musl-arm;osx-arm64"
TargetFramework="$(NetCoreAppCurrent)"
Condition="'@(KnownAppHostPack)' == '' or !@(KnownAppHostPack->AnyHaveMetadataValue('TargetFramework', '$(NetCoreAppCurrent)'))" />
<KnownCrossgen2Pack Include="$(LocalFrameworkOverrideName).Crossgen2"
TargetFramework="$(NetCoreAppCurrent)"
Crossgen2PackNamePattern="$(LocalFrameworkOverrideName).Crossgen2.**RID**"
Crossgen2PackVersion="$(ProductVersion)"
Crossgen2RuntimeIdentifiers="linux-musl-x64;linux-x64;win-x64"
Condition="'@(KnownCrossgen2Pack)' == '' or !@(KnownCrossgen2Pack->AnyHaveMetadataValue('TargetFramework', '$(NetCoreAppCurrent)'))" />
</ItemGroup>
<!-- Simple name references will be resolved from the targeting pack folders and should never be copied to the output. -->
<ItemGroup>
<Reference Update="@(Reference)">
<Private Condition="'%(Reference.Extension)' != '.dll'">false</Private>
</Reference>
</ItemGroup>
<!-- DisableImplicitAssemblyReferences support. -->
<Target Name="RemoveFrameworkReferences"
BeforeTargets="_HandlePackageFileConflicts"
AfterTargets="ResolveTargetingPackAssets"
Condition="'$(DisableImplicitAssemblyReferences)' == 'true' and
'$(TargetFrameworkIdentifier)' == '.NETCoreApp'">
<!-- Point MicrosoftNetCoreAppRefPackRefDir to the acquired targeting pack to use it later for AssemblySearchPaths resolution. -->
<PropertyGroup Condition="'$(UseLocalTargetingRuntimePack)' != 'true'">
<MicrosoftNetCoreAppRefPackRefDir>%(ResolvedFrameworkReference.TargetingPackPath)\ref\net$(TargetFrameworkVersion.TrimStart('v'))\</MicrosoftNetCoreAppRefPackRefDir>
</PropertyGroup>
<ItemGroup>
<Reference Remove="@(Reference)"
Condition="'%(Reference.FrameworkReferenceName)' == '$(LocalFrameworkOverrideName)'" />
</ItemGroup>
</Target>
<!-- Add the resolved targeting pack to the assembly search path. -->
<Target Name="UseTargetingPackForAssemblySearchPaths"
BeforeTargets="ResolveAssemblyReferences;
DesignTimeResolveAssemblyReferences"
Condition="'$(TargetFrameworkIdentifier)' == '.NETCoreApp'">
<PropertyGroup>
<AssemblySearchPaths>$(AssemblySearchPaths);$(MicrosoftNetCoreAppRefPackRefDir.TrimEnd('/\'))</AssemblySearchPaths>
<DesignTimeAssemblySearchPaths>$(DesignTimeAssemblySearchPaths);$(MicrosoftNetCoreAppRefPackRefDir.TrimEnd('/\'))</DesignTimeAssemblySearchPaths>
</PropertyGroup>
</Target>
<!-- SDK tries to download runtime packs when RuntimeIdentifier is set, remove them from PackageDownload item. -->
<Target Name="RemoveRuntimePackFromDownloadItem"
Condition="'$(UseLocalTargetingRuntimePack)' == 'true'"
AfterTargets="ProcessFrameworkReferences">
<ItemGroup>
<PackageDownload Remove="@(PackageDownload)"
Condition="'$(UsePackageDownload)' == 'true' and $([System.String]::Copy('%(Identity)').StartsWith('$(LocalFrameworkOverrideName).Runtime'))" />
<PackageReference Remove="@(PackageReference)"
Condition="'$(UsePackageDownload)' != 'true' and $([System.String]::Copy('%(Identity)').StartsWith('$(LocalFrameworkOverrideName).Runtime'))" />
</ItemGroup>
</Target>
<!-- Use local targeting/runtime pack for NetCoreAppCurrent. -->
<Target Name="UpdateTargetingAndRuntimePack"
Condition="'$(UseLocalTargetingRuntimePack)' == 'true'"
AfterTargets="ResolveFrameworkReferences">
<ItemGroup>
<ResolvedTargetingPack Path="$(MicrosoftNetCoreAppRefPackDir.TrimEnd('/\'))"
NuGetPackageVersion="$(ProductVersion)"
PackageDirectory="$(MicrosoftNetCoreAppRefPackDir.TrimEnd('/\'))"
Condition="'%(ResolvedTargetingPack.RuntimeFrameworkName)' == '$(LocalFrameworkOverrideName)' and
Exists('$(MicrosoftNetCoreAppRefPackDir)data\FrameworkList.xml')" />
<ResolvedRuntimePack PackageDirectory="$(MicrosoftNetCoreAppRuntimePackDir)"
Condition="'$(MicrosoftNetCoreAppRuntimePackDir)' != '' and
'%(ResolvedRuntimePack.FrameworkName)' == '$(LocalFrameworkOverrideName)'" />
<ResolvedFrameworkReference TargetingPackPath="$(MicrosoftNetCoreAppRefPackDir.TrimEnd('/\'))"
TargetingPackVersion="$(ProductVersion)"
Condition="'%(Identity)' == '$(LocalFrameworkOverrideName)'" />
</ItemGroup>
</Target>
<!-- Update the local targeting pack's version as it's written into the runtimeconfig.json file to select the right framework. -->
<Target Name="UpdateRuntimeFrameworkVersion"
Condition="'$(UseLocalTargetingRuntimePack)' == 'true'"
AfterTargets="ResolveTargetingPackAssets">
<ItemGroup>
<RuntimeFramework Version="$(ProductVersion)"
Condition="'%(RuntimeFramework.FrameworkName)' == '$(LocalFrameworkOverrideName)'" />
</ItemGroup>
</Target>
<!-- Filter out conflicting implicit assembly references. -->
<Target Name="FilterImplicitAssemblyReferences"
Condition="'$(DisableImplicitAssemblyReferences)' != 'true'"
DependsOnTargets="ResolveProjectReferences"
AfterTargets="ResolveTargetingPackAssets">
<ItemGroup>
<_targetingPackReferenceExclusion Include="$(TargetName)" />
<_targetingPackReferenceExclusion Include="@(_ResolvedProjectReferencePaths->'%(Filename)')" />
<_targetingPackReferenceExclusion Include="@(DefaultReferenceExclusion)" />
</ItemGroup>
<ItemGroup>
<_targetingPackReferenceWithExclusion Include="@(Reference)">
<Exclusion>%(_targetingPackReferenceExclusion.Identity)</Exclusion>
</_targetingPackReferenceWithExclusion>
<Reference Remove="@(_targetingPackReferenceWithExclusion)"
Condition="'%(_targetingPackReferenceWithExclusion.ExternallyResolved)' == 'true' and '%(_targetingPackReferenceWithExclusion.Filename)' == '%(_targetingPackReferenceWithExclusion.Exclusion)'" />
</ItemGroup>
</Target>
</Project>