0

I maintain a number of nuget packages that uses JSON and/or SQL server.

Currently, they have dependencies on Newtonsoft.Json and System.Data.SqlClient but I got requests for supporting System.Text.Json and Microsoft.Data.SqlClient. Updating the code is trivial but what should I do with the nuget packages?

  1. Release new major versions of existing packages
  2. Create new packages

With new major versions, I don't need to update all dependent packages but updates might be confusing for users (e.g. Newtonsoft.Json users must not update major version).

New packages make it more clear but I'm not sure how to name them. Especially if a package is dependent on both JSON and SQL server (i.e. 3 new packages)

I tried to search nuget.org for example but didn't find anything.

Are there recommendations or best practices for situations like this?

Sohail Ahmad
  • 7,309
  • 5
  • 27
  • 46
adrianm
  • 14,468
  • 5
  • 55
  • 102

1 Answers1

1

One option is to have none of those dependencies in your package itself but to extract the common behaviour to an interface and let callers inject their own implementation. That way consumers can take whichever dependencies they like.

A good example is the ILogger interface - libraries log using the interface, and callers can choose to inject whatever implementation they like (e.g. one from Serilog or log4net).

The downside is that if there's no existing interface that suits your needs then you need to provide one (and likely implementations of it as well, packaged up one per dependency so consumers can mix and match).

That's a big breaking change, so I'd consider doing it under a new package name and namespace, and deprecating your existing package.

Using the dependencies in the package name is possible, but you get combinatorial explosion. Common.Logging uses this approach, but had to also include the version number of the deps in the name which makes the explosion even worse (discussion of why here).

Just bumping the major version sounds like a nightmare, especially if people may want to choose the dependencies in the lower version.

rbennett485
  • 1,907
  • 15
  • 24
  • `Common.Logging` have the same problem and their solution seems like the only way. Thank you for the link. – adrianm Mar 09 '20 at 14:31