@@ -182,20 +182,28 @@ Copyright (c) .NET Foundation. All rights reserved.
182182 </PropertyGroup >
183183
184184 <!-- Add conditional compilation symbols for the target framework (for example NET461, NETSTANDARD2_0, NETCOREAPP1_0) -->
185- <PropertyGroup Condition =" '$(DisableImplicitFrameworkDefines)' != 'true' and '$(TargetFrameworkIdentifier)' != '.NETPortable' and '$(TargetFrameworkIdentifier)' != ''" >
186- <_FrameworkIdentifierForImplicitDefine >$(TargetFrameworkIdentifier.Replace('.', '').ToUpperInvariant())</_FrameworkIdentifierForImplicitDefine >
187- <_FrameworkIdentifierForImplicitDefine Condition =" '$(TargetFrameworkIdentifier)' == '.NETCoreApp' and $([MSBuild]::VersionGreaterThanOrEquals($(TargetFrameworkVersion), 5.0)) " >NET</_FrameworkIdentifierForImplicitDefine >
188- <VersionlessImplicitFrameworkDefine >$(_FrameworkIdentifierForImplicitDefine)</VersionlessImplicitFrameworkDefine >
189- <_FrameworkIdentifierForImplicitDefine Condition =" '$(TargetFrameworkIdentifier)' == '.NETFramework'" >NET</_FrameworkIdentifierForImplicitDefine >
185+ <Target Name =" GenerateTargetFrameworkDefineConstants"
186+ Condition =" '$(DisableImplicitFrameworkDefines)' != 'true' and '$(TargetFrameworkIdentifier)' != '.NETPortable' and '$(TargetFrameworkIdentifier)' != ''" >
187+ <PropertyGroup >
188+ <_FrameworkIdentifierForImplicitDefine >$(TargetFrameworkIdentifier.Replace('.', '').ToUpperInvariant())</_FrameworkIdentifierForImplicitDefine >
189+ <_FrameworkIdentifierForImplicitDefine Condition =" '$(TargetFrameworkIdentifier)' == '.NETCoreApp' and $([MSBuild]::VersionGreaterThanOrEquals($(TargetFrameworkVersion), 5.0)) " >NET</_FrameworkIdentifierForImplicitDefine >
190+ <VersionlessImplicitFrameworkDefine >$(_FrameworkIdentifierForImplicitDefine)</VersionlessImplicitFrameworkDefine >
191+ <_FrameworkIdentifierForImplicitDefine Condition =" '$(TargetFrameworkIdentifier)' == '.NETFramework'" >NET</_FrameworkIdentifierForImplicitDefine >
190192
191- <_FrameworkVersionForImplicitDefine >$(TargetFrameworkVersion.TrimStart('vV'))</_FrameworkVersionForImplicitDefine >
192- <_FrameworkVersionForImplicitDefine >$(_FrameworkVersionForImplicitDefine.Replace('.', '_'))</_FrameworkVersionForImplicitDefine >
193- <_FrameworkVersionForImplicitDefine Condition =" '$(TargetFrameworkIdentifier)' == '.NETFramework'" >$(_FrameworkVersionForImplicitDefine.Replace('_', ''))</_FrameworkVersionForImplicitDefine >
193+ <_FrameworkVersionForImplicitDefine >$(TargetFrameworkVersion.TrimStart('vV'))</_FrameworkVersionForImplicitDefine >
194+ <_FrameworkVersionForImplicitDefine >$(_FrameworkVersionForImplicitDefine.Replace('.', '_'))</_FrameworkVersionForImplicitDefine >
195+ <_FrameworkVersionForImplicitDefine Condition =" '$(TargetFrameworkIdentifier)' == '.NETFramework'" >$(_FrameworkVersionForImplicitDefine.Replace('_', ''))</_FrameworkVersionForImplicitDefine >
194196
195- <ImplicitFrameworkDefine >$(_FrameworkIdentifierForImplicitDefine)$(_FrameworkVersionForImplicitDefine)</ImplicitFrameworkDefine >
197+ <ImplicitFrameworkDefine >$(_FrameworkIdentifierForImplicitDefine)$(_FrameworkVersionForImplicitDefine)</ImplicitFrameworkDefine >
196198
197- <BackwardsCompatFrameworkDefine Condition =" '$(TargetFrameworkIdentifier)' == '.NETCoreApp' and $([MSBuild]::VersionGreaterThanOrEquals($(TargetFrameworkVersion), 5.0))" >$(TargetFrameworkIdentifier.Replace('.', '').ToUpperInvariant())</BackwardsCompatFrameworkDefine >
198- </PropertyGroup >
199+ <BackwardsCompatFrameworkDefine Condition =" '$(TargetFrameworkIdentifier)' == '.NETCoreApp' and $([MSBuild]::VersionGreaterThanOrEquals($(TargetFrameworkVersion), 5.0))" >$(TargetFrameworkIdentifier.Replace('.', '').ToUpperInvariant())</BackwardsCompatFrameworkDefine >
200+ </PropertyGroup >
201+ <ItemGroup >
202+ <_ImplicitDefineConstant Include =" $(VersionlessImplicitFrameworkDefine)" />
203+ <_ImplicitDefineConstant Include =" $(ImplicitFrameworkDefine)" />
204+ <_ImplicitDefineConstant Include =" $(BackwardsCompatFrameworkDefine)" />
205+ </ItemGroup >
206+ </Target >
199207
200208 <!-- Add conditional compilation symbols for the target platform (for example ANDROID, IOS, WINDOWS) -->
201209 <Target Name =" GenerateTargetPlatformDefineConstants"
@@ -239,7 +247,7 @@ Copyright (c) .NET Foundation. All rights reserved.
239247 <!-- Remove TRACE when DisableDiagnosticTracing is true -->
240248 <Target Name =" _DisableDiagnosticTracing"
241249 Condition =" '$(DisableDiagnosticTracing)' == 'true'"
242- DependsOnTargets =" GenerateTargetPlatformDefineConstants;GenerateNETCompatibleDefineConstants;GeneratePlatformCompatibleDefineConstants"
250+ DependsOnTargets =" GenerateTargetFrameworkDefineConstants; GenerateTargetPlatformDefineConstants;GenerateNETCompatibleDefineConstants;GeneratePlatformCompatibleDefineConstants"
243251 BeforeTargets =" CoreCompile" >
244252 <ItemGroup >
245253 <_DefineConstantsWithoutTrace Include =" $(DefineConstants)" />
@@ -261,7 +269,7 @@ Copyright (c) .NET Foundation. All rights reserved.
261269 -->
262270 <Target Name =" AddImplicitDefineConstants"
263271 Condition =" '$(DisableImplicitFrameworkDefines)' != 'true' "
264- DependsOnTargets =" GenerateTargetPlatformDefineConstants;GenerateNETCompatibleDefineConstants;GeneratePlatformCompatibleDefineConstants;_DisableDiagnosticTracing"
272+ DependsOnTargets =" GenerateTargetFrameworkDefineConstants; GenerateTargetPlatformDefineConstants;GenerateNETCompatibleDefineConstants;GeneratePlatformCompatibleDefineConstants;_DisableDiagnosticTracing"
265273 BeforeTargets =" BeforeCompile" >
266274 <PropertyGroup >
267275 <DefineConstants Condition =" '@(_ImplicitDefineConstant)' != '' " >$(DefineConstants);@(_ImplicitDefineConstant)</DefineConstants >
0 commit comments