Search code examples
svnprojects-and-solutions

How to structure multiple small solutions with shared common code (moving to SVN)


I am about to migrate our code from VSS2005 to VisualSVN (and at the same time add in TeamCity).

This gives me the one-off chance of restructuring our code files/folders and I'm looking for some advice on how to strucure multiple, small solutions which often contain code either common to their "area" or to every project.

I have lots of small, internal applications - winforms, MVC3 sites, console/service apps etc., usually department specific. Most departments have some "common" code for things they work with, and then there is general common code, such as extension methods, that are common to most projects.

By default VS2010 creates a "Solution" folder containing the .sln file, and then "Project" folders underneath. That means everything is nicely discrete - but sharing projects is more difficult, since projects appear "solution specific"

I know you can reference anything, but on a disc structure it "looks" solution specific

CommonCode
--CCProj1
--CCProj2
HR.ServiceApp
-HR.ServiceApp.sln
--HR.SmallApp1.DAL
--HR.SmallApp1.Service
HR.WinFormsApp
-HR.WinFormsApp.sln
--HR.SmallApp2.DAL
--HR.SmallApp2.WinForms

An alternative could be to structure like this:

CommonCode
--CCProj1
--CCProj2
HR
-HR.Service.sln
-HR.WinForm.sln
--HR.DAL
--HR.Service
--HR.WinForms

which places all HR code under one single folder - but with multiple solutions could become a little unclear for new users?

Any advice on what other people commonly do would be VERY gratefully received (noting the move to SVN especially)


Another alternative

HR
-HR.Common
--HR.Common.Repository
---HR.Common.Repository.sln
----HR.Common.DAL
-----HR.Common.DAL.csproj
----HR.Common.BLL
-----HR.Common.BLL.csproj
-HR.Services
--HR.Services.Service1.sln
---HR.Services.Service1
----HR.Services.Service1.csproj
--HR.Services.Service2.sln
---HR.Services.Service2
----HR.Services.Service2.csproj

Solution

  • I think you must maintain separated the logical software configuration and the SVN structure. I would make the general structure like this:

    - trunk
        - <general structure>
    - branches
        - release_bugfix01
            - <general structure>
        - release02_rc1
            - <general structure>
    - tags
        - release01
        - release02
    

    Where "general structure" is:

     - common_code_1
     - common_code_2
     - project_one
     - project_three
     - winform01
     - humanresources_MVC3_site
     - console_service_app01
    

    The internal structure of projects and common code can be in any shape you want and the logical dependecy among projects and common codes must be defined outside the repository.

    You can read more about the standard layout in the SVN Book