-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
STJ source generation in a WPF project broken #7624
Comments
Analysis of causeAt its core, this stems from having two different versions of the source generator (a type of analyzer) run during a build. This error happens in This task does not use What is specifically happening here is that GenerateTemporaryTargetAssembly is passed the complete list of analyzers that the main compilation used. It pre-adds those as That works fine for deduplicating a source generator that only lives in a nuget package, but does not work for deduping a source generator between an in-box version and one from a nuget package. Temporary workaroundAs a temporary workaround, users can add thr following to their csproj (adjust to be correct culture for main XAML files):
and also add this attribute (with the same value as UICulture property): [assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] This avoids the using Proposed solutionHave GenerateTemporaryTargetAssembly add the analyzers it is passed as new Then instead of
The result of this is that we end up using the exact same set of source generators as regular build, which seems to be the intention, given that the code was already adding them as |
I have same issue in .NET SDK 8.0.301. |
This started occurring for me in .NET 9 |
Related: #10175 |
I attempted to use your solution and when doing a dotnet build it works fine but when using dotnet publish the satellite resource is not being published into the publish directory. Any thoughts as to why? |
Is there any timeline when this will be fixed without the need for the work around? |
Yes this has now affected two of my projects and my final "workaround" was to completely remove all STJ source generation because I could not get this resolved via the suggested workaround. |
We're looking into this. Will keep the thread posted on updates. |
Description
Referencing certain NuGets in a Wpf project and using STJ source generation the build breaks.
Reproduction Steps
Microsoft.Extensions.Hosting
or anything that indirectly depends onSystem.Text.Json
dotnet build
, VS, whateverMinimal repro code: https://gist.github.com/bachratyg/09df487726946b05728d5129044ca574
Expected behavior
Should build just fine
Actual behavior
Output from dotnet build
Regression?
Might be related to #6792 (pull #6793, #6799)
Known Workarounds
None that I found. Tried #6680 (comment) as suggested in #6792, didn't work
Impact
Can't use STJ source generator together with libraries that also depend on STJ. E.g.
BackgroundService
fromMicrosoft.Extensions.Hosting
or stuff fromMicrosoft.Extensions.Configuration.Json
Configuration
Does not seem to be specific to configuration
dotnet --info
Other information
No response
The text was updated successfully, but these errors were encountered: