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

Support multi-targeting for Roslyn components #152

Open
eerhardt opened this issue Aug 30, 2022 · 1 comment
Open

Support multi-targeting for Roslyn components #152

eerhardt opened this issue Aug 30, 2022 · 1 comment

Comments

@eerhardt
Copy link
Member

Opening an issue here to add support for dotnet/sdk#20355 in the ResolveNuGetPackageAssets Task. We need to update the NuGet MSBuild logic with support for multi-targeted Roslyn components. That way developers using non-SDK .NET projects will get the same Analyzers selected as SDK projects.

Any non-SDK style projects that are referencing NuGet packages with multi-targeted Source Generators (ex. System.Text.Json and Microsoft.Extensions.Logging.Abstractions) are not getting the best possible Source Generator loaded. This results in slower builds and IDE interactions because the source generators targeting older Roslyn versions don't have the latest incremental logic in them. They need newer Roslyn versions to fix the performance bugs.

Those NuGet packages have fallback logic when SupportsRoslynComponentVersioning is not true to just pick the oldest supported version. This allows the NuGet package to work with older tools that don't support multi-targeting Roslyn. But when SupportsRoslynComponentVersioning is set to true, the tooling that picks the analyzer assets from the NuGet package will pick the correct Source Generator/Analyzer based on the Roslyn version targeted and the current $(CompilerApiVersion).

We should re-implement the logic that is used in SDK-style projects (dotnet/sdk#20793) in the ResolveNuGetPackageAssets Task.

See also dotnet/roslyn#63522 (comment)

cc @ericstj

@baronfel
Copy link
Member

baronfel commented Jun 4, 2024

This also seems to impact SDK-style projects when an analyzer package includes both an 'unversioned' and a 'versioned' Roslyn analyzer reference - it would be great if ResolveNuGetPackageAssets could protect users from known-impacted package layouts like this. See dotnet/sdk#41352 for reference.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants