dotnet / NuGet.BuildTasks

The build tasks used to pick up package content from project.lock.json.
MIT License
44 stars 60 forks source link

ResolveNuGetPackageAssets does not respect versioned analyzers #182

Closed jaredpar closed 2 months ago

jaredpar commented 2 months ago

The behavior of ResolveNuGetPackageAssets has gotten out of sync with ResolvePackageAssets. A few years ago the ResolvePackageAssets task was updated to understand multi-targeted analyzers. That allows a NuPkg to deploy multiple versions of an analyzer targeted to different versions of the Roslyn API. Since then this behavior's been used in a number of high impact packages like System.Text.Json, Microsoft.Extensions.Logging.Abstractions, etc ...

That behavior was never replicated in ResolveNuGetPackageAssets. This means when a <PackageReference> to one of those NuPkg is done in an old style project it will end up resolving all of the analyzers in the NuPkg. Basically many different versions of the same analyzer. That essentially breaks the build as it can't be interpreted correctly by the compiler.

The NuPkg have tried to work around this by detecting unsuported scenarios and picking the most compatible analyzer. That is a band aid though. It removes one symptom of the problem while causing others. The real fix is getting these two asset resolutions back in sync with respect to features.

jaredpar commented 2 months ago

@tmeschter FYI

jaredpar commented 2 months ago

dupe of #152