Skip to content

Commit

Permalink
Run 'AddImplicitDefineConstants' on 'BeforeCompile'
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergio0694 committed Nov 6, 2024
1 parent a09ad8a commit e894826
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -251,11 +251,18 @@ Copyright (c) .NET Foundation. All rights reserved.
</PropertyGroup>
</Target>

<!-- Add implicitly defined preprocessor symbols to DefineConstants -->
<!--
Add implicitly defined preprocessor symbols to DefineConstants. Note: this is intentionally using 'BeforeCompile' as
trigger to ensure that it runs before the XamlPreCompile targets. This targets creates the intermediate XAML project
that is used by some XAML-based UI frameworks (eg. UWP XAML, WinUI 3). If it runs before AddImplicitDefineConstants,
and the code has any '#ifdefs' on constants generated by this target (eg. 'NET9_0_OR_GREATER'), the intermediate XAML
project will end up selecting the other code paths instead, which can cause all kinds of build failures or other
problems. For additional context, see: https://github.com/dotnet/sdk/issues/43908.
-->
<Target Name="AddImplicitDefineConstants"
Condition=" '$(DisableImplicitFrameworkDefines)' != 'true' "
DependsOnTargets="GenerateTargetPlatformDefineConstants;GenerateNETCompatibleDefineConstants;GeneratePlatformCompatibleDefineConstants;_DisableDiagnosticTracing"
BeforeTargets="CoreCompile" >
BeforeTargets="BeforeCompile" >
<PropertyGroup>
<DefineConstants Condition=" '@(_ImplicitDefineConstant)' != '' " >$(DefineConstants);@(_ImplicitDefineConstant)</DefineConstants>
<FinalDefineConstants Condition=" '@(_ImplicitDefineConstant)' != '' and '$(Language)' == 'VB' " >$(FinalDefineConstants),@(_ImplicitDefineConstant->'%(Identity)=-1', ',')</FinalDefineConstants>
Expand Down

0 comments on commit e894826

Please sign in to comment.