Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best practice to share common libraries between solutions in .NET

We have pool of MSVS solutions (Solution "A", "B", "C", ... ) that share basic functionality in assembly called "Common.dll".

There are 3-5 active solutions (that are under developing) while others are passive and hardly ever be rebuilt.

Common.dll is always under developing. There are several options how to keep my solutions code, what will you suggest and why?

A). Put common.dll source code to every solution. Pros: it will help active solutions to grow with common.dll side-by-side while passive solutions will be compilable. Cons: it's hard to synchronize active common.dll code between active solutions

B). Put common.dll binary code to every solution. Pros: all projects will be compilable while common.dll code will be centralized. Cons: it's hard to grow active solutions side-by-side with common.dll

C). Reference every project to last common.dll binaries looks like B. but it'll bring problems with passive solutions if common.dll will grow and change it's interfaces (some may say interfaces should always stay constant)

D). ?

Thank you in advance!

like image 341
Andrew Florko Avatar asked Jan 16 '12 11:01

Andrew Florko


People also ask

Can two projects reference each other C#?

This can be achieved by adding reference of one project in the other project. If both the projects are in the same solution, then expand the project name, right click on 'References', click on Add references. Go to 'Projects' Tab, select the project name which you want to use in current project, click ok.

How do I share code between projects in Visual Studio?

If you select Start Collaboration session from the Session Details menu, an invitation link to your session will automatically be copied to your clipboard. You can share this link with anyone you'd like to collaborate with, as long as they also have VS Code and the Live Share Extension Pack downloaded.

When should you use the .NET core class library project type?

Use a . NET Core library when you want to increase the . NET API surface area your library can access, and you are okay with allowing only . NET Core applications to be compatible with your library.


1 Answers

There are other options, also:

D) Put all projects inside the same SVN (or other CVS) root.

This allows branching and tagging while making sure you have a consistent version of Common branched with every project. This way you simply include the project in each solution as needed.

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

What's good about it is that you are sure to get a snapshot of your Common.dll's source code in every branch you create.

E) Use SVN Externals

If you're using Subversion, you can use SVN Externals (mapping a local subfolder to a url of a versioned resource). GIT supports something similar too, but it's a bit complicated if you want to submit changes to the external repos.

like image 85
Groo Avatar answered Nov 16 '22 07:11

Groo