How to structure multiple overlapping solutions / projects in .Net

code-organizationdeploymentprojects-and-solutionsversion control

I recently started out working for a new client with an old legacy codebase in which there are multiple .net solutions, each typically hosts some projects unique to that solution but then "borrows" / "links in" (add existing project) some other projects which technically belongs to other solutions (at least if you go by the folder structure in TFS)

I have never seen a setup this intertwined, there is no clear build order, sometimes a project in solution A just reference dlls directly from the output directory of a project hosted in solution B, sometimes the project has just been included directly even if it resides FAR away in the folder structure.

It looks like everything has been optimized for developer laziness.

When I confronted them with why they didn't have a CI server they responded that it is hard to set up with the code organized like it is. (I'm setting it up now and cursing this code-organization)

The solutions are organized around deployment artifacts (stuff that needs to be deployed together are in the same solution) which I think is a wise decision, but the contents of those solutions (the projects) are all over the place.

Is there a consensus of a best practice to use when reusing common class libraries across multiple solutions / deployment artifacts,

  • How to structure code in the VCS
  • How to facilitate sharing of business logic between separate deployment artifacts

Best Answer

I have never been a fan of including existing projects that belong to other solutions. There are too many variables where making an edit to that project for 1 solution completely breaks something in another solution. Then by fixing that problem you end up breaking the original solution. Lather, rinse, repeat.

When this kind of dependency leaks into multiple solutions, I like to separate out the dependent code into its OWN solution and create a black-box library that is then included as a reference. My thinking is that your solutions were intertwined so that debugging could be done all the way into the shared project for every solution. If the library is built and tested properly, this kind of debugging really isn't necessary. The library should be able to stand on its own merits and should be tested thoroughly so that the expectations of any consumer project would be met consistently.

Related Topic