Imagine I have:
- A .NET (Unity) game which supports modding
- It loads mods that are .NET assemblies, that can bring their dependencies (deps DLLs end up in the same folder that the mod DLL)
- They use different versions of an utility dependency library, ideally published on NuGet.
Now I’m the author of that third-party utility library.
I’d like that mods can consume it without being worried of assembly version conflicts. For example, ModOne loads Utility 1.0.0 and ModTwo loads Utility 2.0.0.
The default in this case is that the most recent version of the assembly (or the first being loaded, I’m not sure) wins and one of the mods will break.
I’m seeking advice on how to solve this without being a nightmare of configuration for mod authors.
I’ve searched the web a lot, but there’s nothing quite clear and definitive for my specific use case.
Two alternatives I’m considering:
- Create a strong-named assembly dependency. Can mod authors reference it via
<PackageReference>
, then use<Reference>
to specify the publick key token, and then use an alias to force the use of a specific version. Would that even work? I can also skip NuGet and directly provide a downloadable .dll if that helps. - Publish new versions but adding new namespaces as breaking changes occur, ex.
UtilityLib.Feature.V2
. It would work as long as it’s always the newest assembly version that is loaded, but I don’t know if it’s always the case, seems dependent on the .NET runtime is use, and I don’t know how the game/Unity handles this. No explicit assembly binding redirect is possible to my knowledge because we don’t control the config of the game. - Publish the dependency as a mod, but for various reasons I’d like to avoid this solution.
I seek specific guidance on this problem, as similar questions but for slightly different use cases have already been answered, generally in a vague manner. Not being extremely familiar with .NET, I’m at a loss.
In conclusion: is possible at all to do that in .NET in a deterministic way that doesn’t involve heavy workarounds and complicated setup for mod authors, or should I give up?