In my effort to bring a good development environment for the next version of Tech Head Brothers portal, in which we should be (at the moment) three to develop, I went on with the integration of NDepend, the wonderful tool of Patrick Smacchia, with the just as well JetBrains Team City build management server.

As said in my last post I have defined three builds type

  1. Continuous Integration - running compilation, unit testing, code coverage and deployment on staging
  2. Nightly build - to find duplicates in the code
  3. Nightly build - running compilation, unit testing, code coverage and code analyze

NDepend is integrated in the 3rd point during this nightly build for the code analyze.

My solution in Visual Studio is organized as the following:

In which you can see

  1. a Visual Studio 2008 Web Deployment Projects which I customized to carry out the different build tasks for the 3 different built types (Continuous Integration, Nightly duplicates and Nightly full analyze): TechHeadBrothers.Portal.csproj_deploy, this is just a MSBuild script
  2. The configuration file for NDepend: TechHeadBrothers.Portal.xml

The next thing I used is to define new configuration:

Nightly and Staging configuration are new one based on the Debug configuration. This will help me to control my MSBuild script with the two build types I am interested about: Continuous Integration = Staging, Nightly = Nightly (obvious ;).

Let’s take a look at the MSBuild script with the new “Open Project File” menu in Visual Studio 2008:

First I am importing the MSBuild tasks exposed by NDepend like this:

AssemblyFile=”$(NDependPath)\MSBuild\NDepend.Build.MSBuild.dllTaskName=”NDependTask“ />

Then defining some properties that will ease the build script writting later on:


C:\Program Files_Tools\Development\ndepend
$(TestsFolder)\NDepend\TechHeadBrothers.Portal.xml
“$(SolutionFolder)\Sources\TechHeadBrothers.Portal\bin”;”C:\Windows\Microsoft.NET\Framework\v2.0.50727”;
$(TestsFolder)\Output\NDependOut

Then I define a Target for NDepend:

Name=”NDepend“>
Text=”#——— Executing NDepend ———#“ />
NDependConsoleExePath=”$(NDependPath)
ProjectFilePath=”$(NDependProjectFilePath)
InDirsDotComaSeparated=”$(NDependInDirs)
OutDir=”$(NDpendOutputDir)“ />

Then in the after build target I call the NDepend target if the configuration is the Nightly one:

Name=”AfterBuild“>
Condition=” ‘$(Configuration)’ == ‘Staging’ Targets=”SummaryCoverageContinueOnError=”false“ />
Condition=” ‘$(Configuration)’ == ‘Nightly’ Targets=”FullCoverageContinueOnError=”false“ />
Condition=” ‘$(Configuration)’ == ‘Nightly’
Targets=”NDepend
ContinueOnError=”false“ />

Now what we want to have is the possibility to see the report generated by NDepend on the Team City portal like this:

To achieve this like for NCover (Integration of NCover into Team City for Tech Head Brothers) we have to configure Team City to deal with the artifacts that NDepend creates, so in the settings of your build you need to define the following:

Then you need to edit on the build server the file main-config.xml and add the following configuration:

Beware not to have two title with the same value!

You will get access also to all created artifacts through the artifacts tab of Team City:

Remark: It would be really nice to be able to have a RSS Feed that would expose the artifacts created! I hope to see this feature in a next release of Team City!

Happy build management!