C#C
C#3y ago
Ploxi

❔ How to Package Multiple Versions of a Library Targeting Different Dependency Versions into a Nuget

I am working on a C# library (mylib) which has a dependency on another library (thatlib).
Now, the problem is, that thatlib has breaking changes between versions 1.0 and 2.0, and I need to support both versions of thatlib in my library.
I need to create two different versions of mylib, each targeting different versions of thatlib, and package them into a single NuGet package. Here are the version ranges I am targeting:

  1. mylib_v1 targeting thatlib versions [1.0,2.0)
  2. mylib_v2 targeting thatlib versions [2.0,5.0)
I want to achieve this ideally using a single .csproj file without creating separate projects for each version. My goal is to ensure that consumers of my library get the correct version of mylib based on the version of thatlib they are using.
Was this page helpful?