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

'AddImplicitDefineConstants' runs too late, and defines are missing when 'XamlPreCompile' runs, causing build failures #43908

Open
Sergio0694 opened this issue Oct 4, 2024 · 0 comments
Labels
Area-NetSDK untriaged Request triage from a team member

Comments

@Sergio0694
Copy link
Contributor

Sergio0694 commented Oct 4, 2024

Describe the bug

WinUI 3 and UWP apps (perhaps WPF/MAUI ones too?) use the XamlPreCompile task defined in the .NET SDK, which creates the intermediate .dll necessary for XAML compilation. The AddImplicitDefineConstants target runs before 'CoreCompile', but this seems to be too late and after 'XamlPreCompile' has already run. This causes the intermediate XAML build to not see the _OR_GREATER defines, meaning it will fail when those are used to exclude incompatible code, and resulting in very weird errors for someone looking at the IDE (which will show the code as being completely fine).

I hit this while migrating the Microsoft Store to .NET 9.

Can we make this target use BeforeTargets="BeforeCompile" or something, to address this?

To Reproduce

Create a WinUI 3 or UWP .NET 9 app with the following code behind:

#if !NET8_0_OR_GREATER
#error GenerateNETCompatibleDefineConstants didn't run 
#endif

Expected result

Should build as expected and match the behavior in the IDE.

Actual result

image

Further technical details

  • Binlog (MSFT only)
  • VS 17.12 P3
@dotnet-issue-labeler dotnet-issue-labeler bot added Area-NetSDK untriaged Request triage from a team member labels Oct 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-NetSDK untriaged Request triage from a team member
Projects
None yet
Development

No branches or pull requests

1 participant