Best practices for sharing shared libraries between solutions in .NET.

We have a MSVS solution pool (solutions "A", "B", "C", ...) that share the main functions in the assembly called "Common.dll".

There are 3-5 active solutions (which are under development), while others are passive and almost never rebuild.

Common.dll is always under development. There are several options for saving the code for my solution, what do you suggest and why?

BUT). Put the source code of common.dll in every solution . Pros: it will help active solutions grow with common.dll side by side, while passive solutions will compile. Cons: it is difficult to synchronize the active common.dll code between active solutions

IN). Add the common.dll binary to each solution . Pros: all projects will be compiled, and the common.dll code will be centralized. Cons: hard to create proactive solutions side by side with common.dll

FROM). The link to each project for the latest common.dll binaries looks like B., but this will cause problems with passive solutions if common.dll grows and changes its interfaces (some may say that the interfaces should always remain constant)

D).?

Thank you in advance!

+7
source share
3 answers

We practice something more like B.

The CI server ensures that shared libraries are always up to date (even if they use other shared libraries). Each solution that uses shared libraries has a β€œLib” folder in which we place assembly artifacts, but they are not under source control (unlike external artifacts such as those imported using NuGet).

Thus, during development, you do not get problems due to violation of changes in shared libraries, and the developer chooses the point in time when he is updated (but he must always do this before making a central repo).

The CI server will always copy the latest common libraries into the "Lib" assembly solutions to integrate the latest shared libraries. If we need to create an assembly with old libraries (a specific version of the fix is ​​very rare), we can always use assembly artifacts with the corresponding date. Regular patch / patch updates are usually also updated to the latest shared libraries.

+1
source

There are other options:

D) Put all projects inside one SVN (or another CVS).

This allows for branching and tagging, ensuring that you have a consistent version of Common with branching with each project. Thus, you simply include the project in each solution as needed.

The problem, of course, is that all projects are inside the same SVN. :)

What's good is that you are sure to get a snapshot of the Common.dll source code in each branch that you create.

E) Use external external SVN elements

If you use Subversion, you can use SVN Externals (mapping a local subfolder to a resource URL with a version). GIT supports something similar , but it's a little complicated if you want to push changes to external repositories.

+2
source

I would say that the discount (A) at once, since you will kill any opportunity that you have for maintainability!

In fact, it comes down to how often these code bases change.

Our current solution on a similar setup I'm working on is to have a separate β€œshared” project, and the binaries are copied to the β€œLibs” folder for each project that references Common. The reason for this is that we have the ability to deploy explicit versions of common.dll for each project. The Libs folder is supported through TFS. Therefore, as long as the original project does not need to be recompiled, TFS will see a new registration and can act accordingly.

Another option that I would consider is to link to a generic in situ project in accordance with one of the solutions on this link . Please note that this limits your ability to link to different versions of the common ones if you do not create separate versions of projects for each physical version, which would be unlikely and impractical, again because of maintainability.

+1
source

All Articles