Exclude Paket incorporated analyzers from dotnet pack
In a reasonable VS solution, we use Paket to manage all our dependencies including some Roslyn-based analyzers. Some of our C# projects are also packed and published as NuGet packages for other clients. This process is triggered via dotnet pack.
Unfortunately, the dependencies on the analyzers are also stated in the package metadata; therefore, these analyzers get incorporated in client projects where they are not wanted.
We found some advice with the copy_local: true|false directive. But it makes no difference if we try out to exclude analyzer dependencies that way. Maybe we didn't get it correctly? Is this the intended approach?
If this doesn't work, we have these ideas:
- Create a script that comments out the analyzer dependencies in the
paket.referencesfiles and then executespaket installto remove them before we trigger a build and pack workflow. It's a bad practice because the created & published packages might not have the same transient dependencies as during the development. - Create an additional
packaginggroup and duplicate themaingroup without the analyzers into it and use it for the build and packaging process. This is annoying because of the duplication. Again the same bad practice. - Move to
paket packwith template files where we can exactly specify the dependencies. But this is somehow "not wished" because of the risk to forget something.
What's your recommendation to proceed?