From 44696c88a42fea9078a9d0a3fc35a778cbb54b74 Mon Sep 17 00:00:00 2001 From: Doug Bunting <6431421+dougbu@users.noreply.github.com> Date: Fri, 28 Aug 2020 12:25:10 -0700 Subject: [PATCH] Use `$(TargetFrameworkIdentifier)` and `$(TargetFrameworkVersion)` consistently - always use `$([MSBuild]::VersionXYZ(...))` for version checks - use `$(NETCoreAppFrameworkIdentifier)` where it's available - move `$(KnownAppHostPackOrFrameworkReferenceTfm)` setting to Directory.Build.props - use it to correct `@(KnownFrameworkReference)` updates - metadata of those items still uses `netcoreapp5.0` - see also https://github.com/dotnet/efcore/pull/22279#discussion_r478674176 nits: - do not assume `$(TargetFrameworkVersion)` starts with a 'v'; valid w/o it - add `$(_IsMicrosoftNETCoreApp20OrOlder)` property in OpenAPI targets file - evaluate the `Condition` once instead of three times --- Directory.Build.targets | 12 +++++++++--- eng/Workarounds.targets | 9 +++------ eng/targets/CSharp.Common.targets | 2 +- .../netstandard2.0/Sdk.Razor.CurrentVersion.targets | 12 ++++++++---- ...icrosoft.Extensions.ApiDescription.Server.targets | 12 ++++++++---- .../dotnet-watch/src/assets/DotNetWatch.targets | 4 ++-- 6 files changed, 31 insertions(+), 20 deletions(-) diff --git a/Directory.Build.targets b/Directory.Build.targets index d4a4e9a2a04d..34e36b4b06bd 100644 --- a/Directory.Build.targets +++ b/Directory.Build.targets @@ -134,14 +134,20 @@ $(AspNetCoreMajorVersion).$(AspNetCoreMinorVersion).0.0 + + $(DefaultNetCoreTargetFramework) + netcoreapp$(TargetFrameworkVersion.TrimStart('vV')) + + - $(MicrosoftNETCoreAppRuntimeVersion) + $(MicrosoftNETCoreAppRuntimeVersion) - $(MicrosoftNETCoreAppRuntimeVersion) + $(MicrosoftNETCoreAppRuntimeVersion) - $(MicrosoftNETCoreAppRefPackageVersion) + $(MicrosoftNETCoreAppRefPackageVersion) diff --git a/eng/Workarounds.targets b/eng/Workarounds.targets index a2cc87f1a07b..863e0c471638 100644 --- a/eng/Workarounds.targets +++ b/eng/Workarounds.targets @@ -22,7 +22,9 @@ - + @@ -40,11 +42,6 @@ - - $(DefaultNetCoreTargetFramework) - netcoreapp5.0 - - - net$(TargetFrameworkVersion.Substring(1).Replace('.','')) + net$(TargetFrameworkVersion.TrimStart('vV').Replace('.','')) .NETFramework diff --git a/src/Razor/Microsoft.NET.Sdk.Razor/src/build/netstandard2.0/Sdk.Razor.CurrentVersion.targets b/src/Razor/Microsoft.NET.Sdk.Razor/src/build/netstandard2.0/Sdk.Razor.CurrentVersion.targets index 59c8868339b9..b5b91fb8f243 100644 --- a/src/Razor/Microsoft.NET.Sdk.Razor/src/build/netstandard2.0/Sdk.Razor.CurrentVersion.targets +++ b/src/Razor/Microsoft.NET.Sdk.Razor/src/build/netstandard2.0/Sdk.Razor.CurrentVersion.targets @@ -38,9 +38,10 @@ Copyright (c) .NET Foundation. All rights reserved. - <_TargetFrameworkVersionWithoutV>$(TargetFrameworkVersion.TrimStart('vV')) - <_TargetingNETCoreApp30OrLater Condition="'$(TargetFrameworkIdentifier)' == '.NETCoreApp' AND '$(_TargetFrameworkVersionWithoutV)' >= '3.0'">true - <_TargetingNET50OrLater Condition="'$(TargetFrameworkIdentifier)' == '.NETCoreApp' AND '$(_TargetFrameworkVersionWithoutV)' >= '5.0'">true + <_TargetingNETCoreApp30OrLater Condition=" '$(TargetFrameworkIdentifier)' == '.NETCoreApp' AND + $([MSBuild]::VersionGreaterThanOrEquals('$(TargetFrameworkVersion)', '3.0')) ">true + <_TargetingNET50OrLater Condition=" '$(TargetFrameworkIdentifier)' == '.NETCoreApp' AND + $([MSBuild]::VersionGreaterThanOrEquals('$(TargetFrameworkVersion)', '5.0')) ">true - true + true diff --git a/src/Tools/dotnet-watch/src/assets/DotNetWatch.targets b/src/Tools/dotnet-watch/src/assets/DotNetWatch.targets index 7ef050fc8c20..26316b06e190 100644 --- a/src/Tools/dotnet-watch/src/assets/DotNetWatch.targets +++ b/src/Tools/dotnet-watch/src/assets/DotNetWatch.targets @@ -11,8 +11,8 @@ them to a file. DependsOnTargets="_CollectWatchItems"> - <_IsMicrosoftNETCoreApp31OrNewer - Condition="'$(TargetFrameworkIdentifier)' == '.NETCoreApp' And $([MSBuild]::VersionGreaterThanOrEquals($(TargetFrameworkVersion), '3.1'))">true + <_IsMicrosoftNETCoreApp31OrNewer Condition="'$(TargetFrameworkIdentifier)' == '.NETCoreApp' AND + $([MSBuild]::VersionGreaterThanOrEquals('$(TargetFrameworkVersion)', '3.1'))">true <_IsMicrosoftNETCoreApp31OrNewer Condition="'$(_IsMicrosoftNETCoreApp31OrNewer)' == ''">false