Skip to content

Commit

Permalink
Simplify logic for IncludePlatformAttributes (#51575)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffhandley authored Apr 20, 2021
1 parent de591a8 commit 466deef
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions src/libraries/Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -229,18 +229,18 @@
<ExcludeFromPackage Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', '$(NetCoreAppCurrent)')) and '$(ExcludeCurrentNetCoreAppFromPackage)' == 'true'">true</ExcludeFromPackage>
</PropertyGroup>

<!-- Adds System.Runtime.Versioning*Platform* annotation attributes to < .NET 5 builds -->
<Choose>
<When Condition="'$(IncludePlatformAttributes)' == 'false'" />
<When Condition="('$(IncludePlatformAttributes)' == 'true' or '$(SupportedOSPlatforms)' != '' or '$(UnsupportedOSPlatforms)' != '') and ('$(TargetFrameworkIdentifier)' != '.NETCoreApp' or $([MSBuild]::VersionLessThan($(TargetFrameworkVersion), '5.0')))">
<!-- If a project is downlevel from net5.0 but uses the platform support attributes, then we include the classes
in the project as internal. If a project has specified assembly-level SupportedOSPlatforms or UnsupportedOSPlatforms,
we can infer the need without having IncludePlatformAttributes set. -->
<ItemGroup>
<Compile Include="$(CoreLibSharedDir)System\Runtime\Versioning\PlatformAttributes.cs" Link="System\Runtime\Versioning\PlatformAttributes.cs" />
</ItemGroup>
</When>
</Choose>
<!-- If a project is downlevel from net5.0 but uses the platform support attributes, then we include the
System.Runtime.Versioning*Platform* annotation attribute classes in the project as internal.
If a project has specified assembly-level SupportedOSPlatforms or UnsupportedOSPlatforms,
we can infer the need without having IncludePlatformAttributes set. -->
<PropertyGroup>
<IncludePlatformAttributes Condition="'$(IncludePlatformAttributes)' == '' and ('$(SupportedOSPlatforms)' != '' or '$(UnsupportedOSPlatforms)' != '')">true</IncludePlatformAttributes>
</PropertyGroup>

<ItemGroup Condition="'$(IncludePlatformAttributes)' == 'true' and ('$(TargetFrameworkIdentifier)' != '.NETCoreApp' or $([MSBuild]::VersionLessThan($(TargetFrameworkVersion), '5.0')))">
<Compile Include="$(CoreLibSharedDir)System\Runtime\Versioning\PlatformAttributes.cs" Link="System\Runtime\Versioning\PlatformAttributes.cs" />
</ItemGroup>

<!-- Adds ObsoleteAttribute to projects that need to apply downlevel Obsoletions with DiagnosticId and UrlFormat -->
<Choose>
Expand Down

0 comments on commit 466deef

Please sign in to comment.