Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run 'AddImplicitDefineConstants' on 'BeforeCompile' #44695

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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