© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
154 replies
Ploxi

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

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

1.
mylib_v1
mylib_v1
targeting
thatlib
thatlib
versions
[1.0,2.0)
[1.0,2.0)

2.
mylib_v2
mylib_v2
targeting
thatlib
thatlib
versions
[2.0,5.0)
[2.0,5.0)


I want to achieve this ideally using a single
.csproj
.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
mylib
based on the version of
thatlib
thatlib
they are using.
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements
Next page

Similar Threads

Nuget Package: Project Reference Mutli Runtime Targeting
C#CC# / help
2y ago
❔ Help with possible conflicts between different versions of a package
C#CC# / help
4y ago
✅ [Nuget] How to find the latest version of a package?
C#CC# / help
15mo ago
Packaging a non-C# binary into a NuGet package.
C#CC# / help
3y ago