I'm creating a NuGet package (let's call it Lib
) that also has analyzers in a separate package (Lib.Analyzers
).
By default I want Lib.Analyzers
to be installed to the the project when Lib
is installed. I can achieve this by listing Lib.Analyzers
in the dependencies of Lib
(in the .nuspec
file).
But I also want users to be able to uninstallLib.Analyzers
again when they don't want them.
AFAIK package dependencies are not listed as individual packages in the package manager and the following wouldn't work in the package manager console:
PM> Install-Package Lib...PM> Uninstall-Package Lib.AnalyzersUninstall-Package : Package 'Lib.Analyzers' to be uninstalled could not be found in project 'ClassLibrary1'
Is there a way to achieve this? I couldn't find anything in the docs.
Rationale
I want to minimize friction for new users, i.e. they should get the help Lib.Analyzers
provides without having to remember to install the analyzers every time they install Lib
.
But I also want Lib.Analyzers
to not be forced onto experienced users that might not want them anymore.
Workaround
My current workaround would be to rename Lib
to Lib.Core
, remove its dependency to Lib.Analyzers
and create a third meta-package named Lib
that bundles the two, arriving at the following dependency graph:
Lib|- Lib.Core'- Lib.Analyzers
New users would then always install Lib
and experienced ones could install only Lib.Core
instead.
However, Lib
is actually a rather small library so this solution feels a little "over-engineered".