Reputation: 2238
I've got a huge application that is split into tens (hundrets ?) of smaller C# projects. In order to build it I simply invoke
msbuild my_root_project.csproj
as the root project simply imports all the required subprojects (which can import other subprojects, which can import other subprojects, ...). This works fine as MSBuild traverses all the dependencies and builds them one by one. As a result I end up with a bunch of dlls in my build output folder (e.g. Debug).
What matters here is that's quite an old project coming from the pre-NuGet times. So there's nothing like a single file with a summary of all the external dependencies. Instead, I've got all the external binaries stored in "ext_libs" folder in the following way:
root
|-> src
|-> CsProject1
|-> CsProject2
....
|-> YetAnotherCsProject
....
|-> MyRootProject
....
|-> ext_libs
|-> Newtonsoft.Json
|-> ... dlls
|-> SevenZip (same here)
|-> ... dlls
|-> ...
These external binaries can be referenced in any of the CsProjects. Moreover, it is even possible that the same library is imported by several subprojects used by my root project (e.g. many of them use Newtonsoft.Json).
I need to get an exact list of all the libraries from ext_libs folder that is used either by my root project or any of its dependent projects.
I've taken a look at MSBuild output logs and noticed that it provides messages like this one:
Building project XYZ.csproj /reference:ext_libs/lib1.dll /reference:ext_libs/lib2.dll ...
...
...
Building project ABC.csproj /reference:ext_libs/lib5.dll /reference:ext_libs/lib23.dll
...
Since MSBuild proves to be able to traverse all the dependencies and resolve all the dependencies one by one. I wonder if it can be somehow instructed do something like:
msbuild /dontBuild /listReferences
Alternatively I could just traverse all the csproj files manually, but obviously I'd prefer to use existing tools instead of creating custom ones.
Upvotes: 2
Views: 2529
Reputation: 16081
I wrote a tool to help in situations like this.
https://github.com/chris1248/SolutionBuilder
Point it to a directory and it will generate a solution file for you containining all the .csproj and .vcxproj files. It spits out a .dgml file which you can open in visual studio and examine your project dependencies in a graph format.
If it doesn't do exactly what you are looking for, you can fork it and modify it to suit your needs.
Upvotes: 3