We have started to include Roslyn analyzers with some of our libraries to make the features of those libraries more discoverable by our developers.
To facilitate this we have a shared library that the analyzers use. So we have the shared component, Company.Roslyn.dll
and Company.Collections.VisualStudio.dll
contains the analyzers and has a dependency on this shared component. When we create our nuget for Company.Collections
we include the dependency like so:
<file src="Build\Company.Collections.VisualStudio.dll" target="analyzers\dotnet\cs" />
<file src="Build\Company.Roslyn.dll" target="analyzers\dotnet\cs" />
When the installer runs it adds both dlls as analyzers to the project file.
Now we have created a second analyzer dll with a dependency on the same Company.Roslyn.dll
we end up with 2 instances of this in the analyzer list in the project.
My first question is, is this correct? The Company.Roslyn.dll
does not actually contain any analyzers, so should it be added as an analyzer? If I don't do this then in some situations I get a warning saying that the dependency should be added as an analyzer...
My second more general question is how should we manage dependencies for analyzers, my feeling is that they should just get deployed in the folder, and not be analyzers, so is it just the default install.ps1
script that has the issues and this should only add actual analyzer dlls?
In VS 2015, adding only the analyzer.dll was not enough. All references had to be added as well. I'm not sure if this was improved in VS2017.
Having the same dependency for two separate analyzers is generally not a problem. Although the dependency shows up twice in the solution explorer tree, VS will only load the DLL into memory once. (Except if the DLL is strongly typed, and you deploy two different versions) Note that the dependencies are also shared between nuget analyzer packages and analyzer VSIX extensions.