WPF project build breaks because Roslyn Source Generators do not run in WPF inner-build
See original GitHub issue- Create a new WPF project.
- Add a PackageReference to any source generator.
- Add code to
MainWindow.xaml.cs
that depends on the generated code. - 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:
The inner build invocation of Csc
does not:
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:5 (4 by maintainers)
Top Results From Across the Web
Source Generator not functioning with XAML files in .NET 6
This seems to be a regression bug with the current release of .NET SDK 6.0.302, and the fix is either a slight change...
Read more >C# Source Generator not including results from Project ...
I'm trying to setup a source generator to be run from a local project reference but can't get it to actually run. My...
Read more >VS 2019 fails to build WPF projects
Visual Studio compiles the projects again to run the unit test, and now Project A fails to compile and reports multiple errors saying...
Read more >NET 6 WPF project won't build
Trying to use this version of SA to obfuscate a simple WPF .NET 6 test app results in the following error when building...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Would you consider making this on by default in 6.0 SDK’s ?
Thanks for reporting this, @AArnott.
Source generator support was added with https://github.com/dotnet/wpf/pull/3846.
This is an opt-in feature. To use it, set the property
IncludePackageReferencesDuringMarkupCompilation
totrue
.I’ll follow-up when I find out which version of the .NET 5.0.xx SDK has the fix.