Building Code at Logos: Repository Layout

We use git for source control, and have adopted a standardised reposistory layout for our projects.

The following example is for a Visual Studio solution on Windows, but can be adapted for other platforms.

Repo\                  -- this is the root of the repository             -- NAnt build script (or equivalent)
  Repo.sln               -- Visual Studio solution file (at root)

  src\                   -- contains primary source code
	Logos.Project\         -- one subfolder per project
	other projects\      -- as above
  tests\                 -- contains tests for each 'src' project
	Logos.Project.Tests\   -- one subfolder per test project
	other test projects\ -- as above

  ext\                   -- contains submodules
	Submodule\             -- third-party source
  lib\                   -- precompiled third-party code
  packages\              -- NuGet packages
	Package.1.0\           -- various packages
	repositories.config    -- configuration

  build\                 -- .gitignore'd, contains build output
  tools\                 -- build tools
	NUnit\                 -- test framework
	other tools\           -- other tools as necessary

At the root of the repository, we have the Visual Studio solution file (used by developers) and the build script (used by the build server). This might be a NAnt build file, a psake build script, a shell script, or something similar.

The src and tests folders contain the bulk of the code we write; this is the code that gets shipped to users or deployed to a web server, and tests that get run by the build server.

ext, lib, and packages contain third-party code (or sometimes Logos code that is consumed as a precompiled binary, rather than as source). Folders under ext are git submodules that reference third-party repos. lib contains pre-compiled DLLs and static libraries. packages is reserved for use by NuGet. (This folder is added to .gitignore if this repo uses NuGet Package Restore.)

build is never committed, but is reserved to contain build output. tools contains code that is required to build the project, but doesn’t get shipped. This would include things like NUnit (or another test framework), StyleCop plugins, NAnt extensions, mocking frameworks, etc.

Posts in the “Building Code at Logos” series:

Posted by Bradley Grainger on November 15, 2012