Skip to content

Commit

Permalink
Don't append TargetOS to .NETFramework tfms (#12288)
Browse files Browse the repository at this point in the history
As .NET Framework tfms don't support TargetPlatform, the TargetOS
property shouldn't be appended to such target frameworks when
calculating the best compatible asset. In addition to that, .NETCoreApp
(.NET 5+) is the only target framework family that is used when
compiling runtime specific assets (i.e. in dotnet/runtime).
  • Loading branch information
ViktorHofer authored Jan 23, 2023
1 parent 4f2548b commit 20e5e15
Showing 1 changed file with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,20 @@
</Target>

<Target Name="GetProjectWithBestTargetFrameworks">
<ItemGroup Condition="'$(BuildTargetFramework)' != ''">
<_BuildTargetFrameworkWithTargetOS Include="$(BuildTargetFramework)-$(TargetOS.ToLowerInvariant())" />
<ItemGroup>
<_BuildTargetFramework Include="$(BuildTargetFramework)"
Condition="'$(BuildTargetFramework)' != ''" />
<_BuildTargetFramework Include="$([MSBuild]::Unescape($([System.Text.RegularExpressions.Regex]::Replace('$(TargetFrameworks)', '(-[^;]+)', ''))))"
Condition="'$(BuildTargetFramework)' == ''" />
</ItemGroup>
<ItemGroup Condition="'$(BuildTargetFramework)' == ''">
<_BuildTargetFrameworkWithoutOS Include="$([MSBuild]::Unescape($([System.Text.RegularExpressions.Regex]::Replace('$(TargetFrameworks)', '(-[^;]+)', ''))))" />
<!-- TODO: Find a better way to filter out non applicable TargetOS values for .NET Framework. -->
<_BuildTargetFrameworkWithTargetOS Include="@(_BuildTargetFrameworkWithoutOS->Distinct()->'%(Identity)-$(TargetOS.ToLowerInvariant())')"
Condition="'$(TargetOS)' == 'windows' or !$([System.String]::Copy('%(Identity)').StartsWith('net4'))" />

<ItemGroup>
<_BuildTargetFrameworkWithTargetOS Include="@(_BuildTargetFramework->Distinct()->'%(Identity)-$(TargetOS)')"
Condition="!$([System.String]::Copy('%(Identity)').StartsWith('net4'))" />
<_BuildTargetFrameworkWithTargetOS Include="@(_BuildTargetFramework->Distinct())"
Condition="$([System.String]::Copy('%(Identity)').StartsWith('net4'))" />
</ItemGroup>

<ChooseBestTargetFrameworksTask BuildTargetFrameworks="@(_BuildTargetFrameworkWithTargetOS);$(AdditionalBuildTargetFrameworks)"
SupportedTargetFrameworks="$(TargetFrameworks)"
RuntimeGraph="$(BundledRuntimeIdentifierGraphFile)"
Expand Down

0 comments on commit 20e5e15

Please sign in to comment.