Paket icon indicating copy to clipboard operation
Paket copied to clipboard

Exclude Paket incorporated analyzers from dotnet pack

Open apm1grb opened this issue 3 years ago • 0 comments

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:

  1. Create a script that comments out the analyzer dependencies in the paket.references files and then executes paket install to 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.
  2. Create an additional packaging group and duplicate the main group 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.
  3. Move to paket pack with 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?

apm1grb avatar Oct 24 '22 18:10 apm1grb