question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue
  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

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
vatsan-madhavancommented, Jan 9, 2021

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

2reactions
ryalanmscommented, Jan 9, 2021

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 to true.

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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found