R – Nant: Building projects using svn-externals

build-processnantproject-structuresvnsvn-externals

Using subversion and Nant for building. I have a main project that depends on several sub-projects. The sub-projects exist as separate projects inside subversion.

My question is:
Should the nant build script in the main project build all the referenced sub projects and itself? Or do the subprojects know how to build themselves and I somehow call the subproject build files from the main build file and somehow assemble all the output into the main projects build output?

I currently have the mainproject build file build all the subprojects. That is, I have nant targets for each subproject in the build file. However, this seems to create a tight coupling between the main build file and the subprojects. It would be nice if I could just say "sub projects know how to build themselves" and ask them to build themselves from the main project and assemble the output.

For reference, my repository looks like:

/Repo
  /MainProject
    /trunk
      /doc   <-- documentation
      /lib   <-- binary-only DLLs (usually 3rd party)
      /src   <-- source code for MainProject
      /svn-externals  <-- hold references to other projects in repository
...
  /ClassLib1
    /trunk
      /doc
      /lib
      /src
      /svn-externals
...
  /ClassLib2
    /trunk
      /doc
      /lib
      /src
      /svn-externals
...
  /ClassLibCommon
    /trunk
      /doc
      /lib
      /src
      /svn-externals

I'm pulling in the sub-projects using the subversion svn-externals property. So my working copy is like this:

/MainProject
  /build
  /doc
  /lib
  /src
    /MainProject
  /svn-externals
    /ClassLib1 <-- svn external to svn://xyz/repo/ClassLib1/trunk
      /doc
      /lib
      /src
      /svn-externals
        /ClassLibCommon <- svn external to svn://xyz/repo/ClassLibCommon/trunk
          ...
    /ClassLib2 <-- svn external to svn://xyz/repo/ClassLib2/trunk
      /doc
      /lib
      /src
      /svn-externals
        /ClassLibCommon <- svn external to svn://xyz/repo/ClassLibCommon/trunk
          ...

Best Answer

The answer to your question is of course "it depends".

What you don't say is how you reference the "sub-projects" in your solution or if they are used by other solutions (main projects)? Are they project references? If so, have nant call MSBuild to build the solution. This will build all the sub projects based on those dependencies. I can only assume this is how you have it set up.

Personally if I had a setup that looked like your I would not use project references nor would I have externals to all the code for each project. I would treat those sub projects the same as you treat your Third Party DLLs.

If you did this you would be using DLL references. This decouples the sub-porjects from your main project. This is the way I would go, especially if those sub-projects are referenced by other projects.

Yes, now you have to make some other decisions... such as how to store those in source control. You can have externals in your lib folder... or you can just put a copy of the DLL into your lib folder. This also depends on how you want to control versioning.

Also, you don't mention if you use some type of CI such as CC.Net. If you did you could have it trigger a rebuild of the main project if any of the sub-projects are modified.