Skip to content

Commit

Permalink
Expose the UseLocalTargetingRuntimePack property (#53290)
Browse files Browse the repository at this point in the history
* Expose the UseLocalTargetingRuntimePack property

and use it in the Microsoft.NETCore.Platforms package to avoid a dependency on the live built targeting and runtime pack / shared framework.

* Update Microsoft.NETCore.Platforms.csproj
  • Loading branch information
ViktorHofer authored May 26, 2021
1 parent 6c31866 commit 1883505
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
12 changes: 6 additions & 6 deletions eng/targetingpacks.targets
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
<PropertyGroup Condition="'$(DisableImplicitFrameworkReferences)' != 'true' and
'$(TargetFrameworkIdentifier)' == '.NETCoreApp' and
$([MSBuild]::VersionGreaterThanOrEquals($(TargetFrameworkVersion), '$(NETCoreAppCurrentVersion)'))">
<_UseLocalTargetingRuntimePack>true</_UseLocalTargetingRuntimePack>
<UseLocalTargetingRuntimePack Condition="'$(UseLocalTargetingRuntimePack)' == ''">true</UseLocalTargetingRuntimePack>
<EnableTargetingPackDownload>false</EnableTargetingPackDownload>
<GenerateErrorForMissingTargetingPacks>false</GenerateErrorForMissingTargetingPacks>
</PropertyGroup>

<!-- Add Known* items if the SDK doesn't support the TargetFramework yet. -->
<ItemGroup Condition="'$(_UseLocalTargetingRuntimePack)' == 'true'">
<ItemGroup Condition="'$(UseLocalTargetingRuntimePack)' == 'true'">
<KnownFrameworkReference Include="$(LocalFrameworkOverrideName)"
DefaultRuntimeFrameworkVersion="$(ProductVersion)"
IsTrimmable="true"
Expand Down Expand Up @@ -69,7 +69,7 @@
'$(TargetFrameworkIdentifier)' == '.NETCoreApp' and
$([MSBuild]::VersionGreaterThanOrEquals($(TargetFrameworkVersion), '3.0'))">
<!-- Point MicrosoftNetCoreAppRefPackRefDir to the acquired targeting pack to use it later for AssemblySearchPaths resolution. -->
<PropertyGroup Condition="'$(_UseLocalTargetingRuntimePack)' != 'true'">
<PropertyGroup Condition="'$(UseLocalTargetingRuntimePack)' != 'true'">
<_NetCoreAppTargetFrameworkIdentifier Condition="$([MSBuild]::VersionLessThan($(TargetFrameworkVersion), '5.0'))">netcoreapp</_NetCoreAppTargetFrameworkIdentifier>
<_NetCoreAppTargetFrameworkIdentifier Condition="$([MSBuild]::VersionGreaterThanOrEquals($(TargetFrameworkVersion), '5.0'))">net</_NetCoreAppTargetFrameworkIdentifier>
<MicrosoftNetCoreAppRefPackRefDir>%(ResolvedFrameworkReference.TargetingPackPath)\ref\$(_NetCoreAppTargetFrameworkIdentifier)$(TargetFrameworkVersion.TrimStart('v'))\</MicrosoftNetCoreAppRefPackRefDir>
Expand All @@ -93,7 +93,7 @@

<!-- SDK tries to download runtime packs when RuntimeIdentifier is set, remove them from PackageDownload item. -->
<Target Name="RemoveRuntimePackFromDownloadItem"
Condition="'$(_UseLocalTargetingRuntimePack)' == 'true'"
Condition="'$(UseLocalTargetingRuntimePack)' == 'true'"
AfterTargets="ProcessFrameworkReferences">
<ItemGroup>
<PackageDownload Remove="@(PackageDownload)"
Expand All @@ -105,7 +105,7 @@

<!-- Use local targeting pack for NetCoreAppCurrent. -->
<Target Name="UpdateTargetingAndRuntimePack"
Condition="'$(_UseLocalTargetingRuntimePack)' == 'true'"
Condition="'$(UseLocalTargetingRuntimePack)' == 'true'"
AfterTargets="ResolveFrameworkReferences">
<ItemGroup>
<ResolvedTargetingPack Path="$(MicrosoftNetCoreAppRefPackDir.TrimEnd('/\'))"
Expand All @@ -123,7 +123,7 @@

<!-- 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'"
Condition="'$(UseLocalTargetingRuntimePack)' == 'true'"
AfterTargets="ResolveTargetingPackAssets">
<ItemGroup>
<RuntimeFramework Version="$(ProductVersion)"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<Project Sdk="Microsoft.NET.SDK">
<PropertyGroup>
<TargetFrameworks>$(NetCoreAppToolCurrent);net472</TargetFrameworks>
<!-- This project should not build against the live built .NETCoreApp targeting pack as it contributes to the build itself. -->
<UseLocalTargetingRuntimePack>false</UseLocalTargetingRuntimePack>
<PackageId>$(MSBuildProjectName)</PackageId>
<AvoidRestoreCycleOnSelfReference>true</AvoidRestoreCycleOnSelfReference>
<AssemblyName>Microsoft.NETCore.Platforms.BuildTasks</AssemblyName>
Expand Down

0 comments on commit 1883505

Please sign in to comment.