testcontainers / testcontainers/testcontainers-dotnet
[Enhancement]: Improving dependency management
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 4.4k
- Forks
- 357
- Avg merge
- 14h 42m
- Merged PRs (30d)
- 16
Description
Problem
Occasionally, we see Testcontainers users run into issues related to incompatible dependencies (dependency resolution). There are two common cases we've noticed:
1. Users of Paket often encounter this issue because Paket uses a different resolution algorithm.
As stated above, the algorithm defaults to resolving the latest versions matching the constraints.
As long as everybody follows semantic versioning and you define sane version constraints (e.g. within a major version) for your direct dependencies the system is very likely to work well.
Unfortunately, this approach makes NuGet package author A dependent on package author B (and everyone else) to strictly follow semantic versioning. Otherwise, users will run into issues. In theory, it's a good approach, but it heavily relies on perfect practices from everyone involved.
- Relates #814
- Relates #1425
- Relates #1458
- Relates #1460
- Relates #1602
🚧 Paket provides a workaround:
To make your transition to Paket easier and to allow package authors to correct their version constraints you can have Paket behave like NuGet by using the
!prefix.
I don't quite understand the following part mentioned in the Paket FAQ. AFAIK, with the default dependency resolution mechanisms in place, developers can override and choose which version of a transitive dependency they want to consume:
Even more importantly: If two packages reference conflicting versions of a package, NuGet will silently take the latest version (read more). You have no control over this process.
2. Sometimes, Testcontainers users mix different versions of modules. For example:
<PackageReference Include="Testcontainers.MsSql" Version="4.3.0" />
<PackageReference Include="Testcontainers.PostgreSql" Version="4.4.0" />
Since these modules share the same underlying base dependency, this can lead to issues. Internal APIs might have changed in version 4.4.0 that aren't compatible with the previous version.
❗ The public APIs are still compatible, so users upgrading from 4.3.0 to 4.4.0 won't encounter breaking changes or any issues.
Are we supposed to pin the third party dependencies? What are we doing with the project references? AFAIK, this isn't supported OOB:
WDYT?
Solution
-
Benefit
Improve the developer experience. Developers shouldn't run into issues when a third party dependency releases a new version.
Alternatives
-
Would you like to help contributing this enhancement?
Yes
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing the dependency reference in src/Testcontainers.MsSql/Testcontainers.MsSql.csproj and the linked NuGet issues about project and transitive dependency resolution. Done means defining an actionable approach for mixed module versions and third-party dependency pinning, with its scope and compatibility expectations documented.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- build-system, developer-experience
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100