Methods of managing source code
I've written a fair amount of software over recent years, most of which all tend to share one or more common libraries. (The most common library, being one that I use for calling SQL stored procedures and returning arrays of objects)
I'm not happy with the way I manage the libraries, and I'm looking for suggestions to improve the way I work.
The first time I created what is now a shared library, I added the library as a separate class library project within the solution.
Now, when I start a new solution and I know I'm going to need a library I already have, I will go and find the library's project and copy the files into the new solution.
This leaves me with several copies of the the same library project dotted around my filesystem (and the SVN server), and it just doesn't feel right.
Is there a better way of working, so that I only have one master copy of this library that all the solutions share, rather than each solution having its own copy of the library project?
Just build the library once, and reference the compiled binary from your project that needs to use it.
In visual studio, right click on the project and click "add reference", then choose the "browse" tab and locate your libraries binary.
(You will obviously need to distribute the library assembly along with your application)
Your feeling is absolutely right. There should be only one master of the library source.
In our shop we have several shared library projects used by several products. We view these libraries as products themselves and treat them accordingly. Specifically, when a project needs one of these libraries we put a compiled version of the library in a lib folder in the project. We remove the need to copy the source around, and our project only references a stable copy of the dll.
Here's a sample structure in the repository
/LibraryX <- product root ../branches ../tags ../trunk <- solution folder ../LibraryX <- project folder ../lib <- thirdparty libraries used by LibraryX /ProductY <- product root ../branches ../tags ../trunk <- solution folder ../ProductY <- project folder ../lib <- thirdparty libraries used by ProductY, e.g. a copy of LibraryX.dll
So, in the ProductY project, rather than including a copy of the LibraryY project you add a reference to the LibraryX.dll located in the lib folder.
I would suggest compiling your library into a dll which can be added as a reference to any other project you are working on. Then you don't need to copy the source files everywhere.
You should just build a dll with your library and then just reference to it..
References > Add Reference in VS.