From d5dfc6d460472e400bd0af44518a81fc73edf14c Mon Sep 17 00:00:00 2001 From: Theodore Tsirpanis Date: Fri, 3 Jan 2025 08:06:45 +0200 Subject: [PATCH] Move generating implicit framework defines to a target. --- .../Microsoft.NET.Sdk.BeforeCommon.targets | 34 ++++++++++++------- .../targets/Microsoft.NET.Sdk.CSharp.targets | 3 -- .../targets/Microsoft.NET.Sdk.FSharp.targets | 4 --- .../Microsoft.NET.Sdk.VisualBasic.targets | 3 -- 4 files changed, 21 insertions(+), 23 deletions(-) diff --git a/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.BeforeCommon.targets b/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.BeforeCommon.targets index 71706dbc7843..f22d26965b40 100644 --- a/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.BeforeCommon.targets +++ b/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.BeforeCommon.targets @@ -182,20 +182,28 @@ Copyright (c) .NET Foundation. All rights reserved. - - <_FrameworkIdentifierForImplicitDefine>$(TargetFrameworkIdentifier.Replace('.', '').ToUpperInvariant()) - <_FrameworkIdentifierForImplicitDefine Condition=" '$(TargetFrameworkIdentifier)' == '.NETCoreApp' and $([MSBuild]::VersionGreaterThanOrEquals($(TargetFrameworkVersion), 5.0)) ">NET - $(_FrameworkIdentifierForImplicitDefine) - <_FrameworkIdentifierForImplicitDefine Condition=" '$(TargetFrameworkIdentifier)' == '.NETFramework'">NET + + + <_FrameworkIdentifierForImplicitDefine>$(TargetFrameworkIdentifier.Replace('.', '').ToUpperInvariant()) + <_FrameworkIdentifierForImplicitDefine Condition=" '$(TargetFrameworkIdentifier)' == '.NETCoreApp' and $([MSBuild]::VersionGreaterThanOrEquals($(TargetFrameworkVersion), 5.0)) ">NET + $(_FrameworkIdentifierForImplicitDefine) + <_FrameworkIdentifierForImplicitDefine Condition=" '$(TargetFrameworkIdentifier)' == '.NETFramework'">NET - <_FrameworkVersionForImplicitDefine>$(TargetFrameworkVersion.TrimStart('vV')) - <_FrameworkVersionForImplicitDefine>$(_FrameworkVersionForImplicitDefine.Replace('.', '_')) - <_FrameworkVersionForImplicitDefine Condition=" '$(TargetFrameworkIdentifier)' == '.NETFramework'">$(_FrameworkVersionForImplicitDefine.Replace('_', '')) + <_FrameworkVersionForImplicitDefine>$(TargetFrameworkVersion.TrimStart('vV')) + <_FrameworkVersionForImplicitDefine>$(_FrameworkVersionForImplicitDefine.Replace('.', '_')) + <_FrameworkVersionForImplicitDefine Condition=" '$(TargetFrameworkIdentifier)' == '.NETFramework'">$(_FrameworkVersionForImplicitDefine.Replace('_', '')) - $(_FrameworkIdentifierForImplicitDefine)$(_FrameworkVersionForImplicitDefine) + $(_FrameworkIdentifierForImplicitDefine)$(_FrameworkVersionForImplicitDefine) - $(TargetFrameworkIdentifier.Replace('.', '').ToUpperInvariant()) - + $(TargetFrameworkIdentifier.Replace('.', '').ToUpperInvariant()) + + + <_ImplicitDefineConstant Include="$(VersionlessImplicitFrameworkDefine)" /> + <_ImplicitDefineConstant Include="$(ImplicitFrameworkDefine)" /> + <_ImplicitDefineConstant Include="$(BackwardsCompatFrameworkDefine)" /> + + <_DefineConstantsWithoutTrace Include="$(DefineConstants)" /> @@ -261,7 +269,7 @@ Copyright (c) .NET Foundation. All rights reserved. --> $(DefineConstants);@(_ImplicitDefineConstant) diff --git a/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.CSharp.targets b/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.CSharp.targets index a10e4eb686e4..50a076e671cb 100644 --- a/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.CSharp.targets +++ b/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.CSharp.targets @@ -30,9 +30,6 @@ Copyright (c) .NET Foundation. All rights reserved. $(ImplicitConfigurationDefine.Replace(' ', '_')) $(DefineConstants);$(ImplicitConfigurationDefine) - - $(DefineConstants);$(VersionlessImplicitFrameworkDefine);$(ImplicitFrameworkDefine);$(BackwardsCompatFrameworkDefine) - diff --git a/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.FSharp.targets b/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.FSharp.targets index 166faba5af2a..7f9117372510 100644 --- a/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.FSharp.targets +++ b/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.FSharp.targets @@ -24,8 +24,4 @@ Copyright (c) .NET Foundation. All rights reserved. - - $(DefineConstants);$(VersionlessImplicitFrameworkDefine);$(ImplicitFrameworkDefine);$(BackwardsCompatFrameworkDefine) - - diff --git a/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.VisualBasic.targets b/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.VisualBasic.targets index c549857ba549..601c3fd49789 100644 --- a/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.VisualBasic.targets +++ b/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.VisualBasic.targets @@ -56,9 +56,6 @@ Copyright (c) .NET Foundation. All rights reserved. - $(FinalDefineConstants),$(VersionlessImplicitFrameworkDefine)=-1 - $(FinalDefineConstants),$(ImplicitFrameworkDefine)=-1 - $(FinalDefineConstants),$(BackwardsCompatFrameworkDefine)=-1 $(FinalDefineConstants),$(ImplicitConfigurationDefine)=-1