SVN Externals — Share common assembly code between solutions

If you are like me and you have a similar problem of having to share common in-house library code between various Visual studio solutions and you are using SVN for your source code control, then SVN Externals might be a good option to consider.

In my scenario, I had a class library which contains a lot of utility classes that are shared amongst different applications I write. Before starting a new project, I would typically create a Solution Items / bin folder in the solution directory of the new project and would place the compiled library dll in this folder which gets checked into SVN repo along with the application code. This approach sort of worked but had the following pain points:

Found out about the SVN externals options and it has helped me great deal in addressing all the above issues, so I thought it might be worthwhile sharing.

Lets say you have a very simple library solution as follows:

image

and it is checked into a SV repo as follows:

image

AppOne and AppTwo folders have 2 different applications that need to share the Utility class in the MyLibrary solution. Both these applications are already checked into the repo in their respective folders.

To add The library code as an external link to AppOne, I had to right click on the AppOne folder, choose properties and the following:

image

To add the library project link, I had to:

image

and the Working copy Subverion properties window looks as follows:

image

Now all that is left to do is right click on AppOne working copy folder and choose SVN update and the Library code would be checked out into AppOne working directory.

image

One of the last things to do is to open the AppOne solution in Visual studio and add the library project by choosing the Add Existing Project option and checking the entire solution back again.

After the solution is checked in this is how the repo browser looked like. It clearly shows MyLibrary.Common with a shortcut icon.

image

The beauty of this approach is that as soon as I make some changes to the library solution, it is immediately reflected in AppOne when I update my working copy.

image

This is how AppOne solution looks like.

image

and any changes made to the Library code from within AppOne would reflect in the Library solution as well.

January 11, 2012 · Common code · Source Code Management · SVN · SVN Externals · Windows Tools


Previous:Simple async in .net 2.0 & Winforms
Next:Simple logging with NLog Application logger