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

WPF project build breaks because Roslyn Source Generators do not run in WPF inner-build #3963

Closed
AArnott opened this issue Jan 8, 2021 · 5 comments

Comments

@AArnott
Copy link

AArnott commented Jan 8, 2021

  1. Create a new WPF project.
  2. Add a PackageReference to any source generator.
  3. Add code to MainWindow.xaml.cs that depends on the generated code.
  4. Build

Expected

No build break

Actual

Build break.

In fact investigating the binary build log reveals that while the outer build's invocation of the Csc task provides the "analyzers" that are actually source generators:
image

The inner build invocation of Csc does not:
image

@ryalanms
Copy link
Member

ryalanms commented Jan 9, 2021

Thanks for reporting this, @AArnott.

Source generator support was added with #3846.

This is an opt-in feature. To use it, set the property IncludePackageReferencesDuringMarkupCompilation to true.

I'll follow-up when I find out which version of the .NET 5.0.xx SDK has the fix.

@vatsan-madhavan
Copy link
Member

Would you consider making this on by default in 6.0 SDK's ?

@ryalanms
Copy link
Member

@AArnott: I believe you validated with 5.0.102-servicing.20614.17. Can this be closed? Thanks.

@AArnott AArnott closed this as completed Jan 13, 2021
@ryalanms
Copy link
Member

Thanks.

@manfred-brands
Copy link

It took me a while to find this issue, only after finding the comment in Microsoft.WinFX.targets.
My issue was not source generators, but a DiagnosticSuppressor from an Roslyn Analyzer nuget package.

@ghost ghost locked as resolved and limited conversation to collaborators Apr 10, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants