-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Description
Properly packaging up analyzers is not automatic. .NET SDK projects that contain analyzers pack themselves with the analyzer assembly in the lib folder instead of the analyzers\cs folder. Fixing this requires suppressing default lib folder placement then writing a custom target to output the right set of assemblies. Care is required to properly suppress all (or most) package dependencies including to Roslyn itself.
StyleCop.Analyzers discovered and others later did as well, the little known fact that analyzers must not reference the roslyn Workspaces package although their code fixes are required to. To do this reliably, one must split these into two assemblies, yet we want to package them up together, which again the .NET SDK pack target makes awkward. Consider a package called My.Analyzers with these assemblies:
My.Analyzers.dll
My.Analyzers.CodeFixes.dll
I tend to want My.Analyzers.CodeFixes.dll to reference My.Analyzers.dll (so that the code fixes can reference the analyzer Id property, share utilities, etc.) But that means I have to make my CodeFixes project do the actual packaging. This is particularly awkward because the package will be given the name of the first project, which NuGet doesn't like unless I give the first project an artificial package ID that won't matter since I need to set IsPackable=false on the analyzer project so that I don't get an analyzer-only package too. Gah! So many things to do. You can see this all in the VSSDK-Analyzers PR that I link to above.
We also have satellite assemblies for some of our analyzers.
Then we have versioning: what version of Roslyn should an analyzer compile against? We want to compile against the latest so we do the right thing when C# 7.1 syntax is encountered, but then we want to keep working on VS2015. Can the package layout include analyzer versions (ala target frameworks) so we can offer analyzer\cs71 and analyzer\cs60 folders side-by-side in the package?
Can all this be simplified, both in build authoring, and with a (multi-)project template in VS?