Reputation: 1263
I have a solution with multiple projects in it and each one of them have their own nuget package. I want to find a way to make one nuget file for the whole solution to avoid different versions of same binaries issue.
Anyone has does this before and can share pointers will help.
Upvotes: 1
Views: 1030
Reputation: 2124
If you have different version of nuget packages already installed, you can use Consolidate tab in package manager to consolidate them.
That will not enforce team members to use consolidated version though, someone still can install another version. If you have a small team, automatic enforcement might be an overkill and you can enforce the same version by educating your team and during code reviews. If you have a big project and several teams working on it, I'd strongly recommend to write a test or pre/post build step which will scan your solution and enforce all projects using the same version of packages.
I don't know if there is any existing package/tool though, that's why please find several possible solutions below:
Just to search PackageReference
elements in csproj
files and parse package.config
if exists to find all referenced projects and then make sure there are no different versions.
This is a simple option but you still might get dll hell with it because of the transitive dependencies. For example: you install Newtonsoft.Json 12.0.0
to your solution and then add Hangfire.PostgreSql 1.6.3
to some project which transitively brings Newtonsoft.Json 10.0.1
.
You can use dotnet list package
to generate a report with all installed packages. If you use --include-transitive
flag, then you could identify potential incompatible versions of transitive dependencies. Unfortunately there is no much you can do in this case: either using another version of the root package which uses the same package that you are using in your solution or just relax and rely on BindingRedirect
s which are automatically generated during package installation.
Upvotes: 1