Jobping Laurent Kempé MVP JetBrains Academy Member Certified ScrumMaster


My status

View Laurent Kempé's profile on LinkedIn

Xbox 360


Locations of visitors to this page

.NET Dudes


French .NET Dudes




Tech Head Brothers

Using NDepend in Team City build management tool

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:

  <UsingTask AssemblyFile="$(NDependPath)\MSBuild\NDepend.Build.MSBuild.dll" TaskName="NDependTask" />

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

    <!-- NDepend -->
    <NDependPath>C:\Program Files\_Tools\Development\ndepend</NDependPath>

Then I define a Target for NDepend:

  <Target Name="NDepend">
    <Message Text="#--------- Executing NDepend ---------#" />
    <NDependTask NDependConsoleExePath="$(NDependPath)" 
                 OutDir="$(NDpendOutputDir)" />

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

  <Target Name="AfterBuild">
    <CallTarget Condition=" '$(Configuration)' == 'Staging' " Targets="SummaryCoverage" ContinueOnError="false" />
    <CallTarget Condition=" '$(Configuration)' == 'Nightly' " Targets="FullCoverage" ContinueOnError="false" />
    <CallTarget Condition=" '$(Configuration)' == 'Nightly' " 
                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:

<report-tab title="Code Coverage Summary" basePath="" startPage="CoverageSummary.html" />
<report-tab title="Code Coverage" basePath="Coverage" startPage="index.html" />
<report-tab title="NDepend" basePath="NDepend" startPage="NDependReport.html" />

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!


John Steward said:


I am new to NCover and TeamCity and I am a little confused about where to define the ncover targets etc.

I have a project containing multiple projects (service, business, data access) and matching test projects (service.test, business.test, data access.test). Now in TeamCity I have defined a build using Sln2008 build runner and am using the nunit settings within teamcity to run the test containers. Where would I define ncover tasks so that coverage for all test assemblies is measured?

Do I need to define the ncover tasks within each and every project file?



# June 30, 2008 4:18 PM

alhambraeidos said:

Can I use NDepend and MSBUILD for analyze SQL files (Oracle) ???

please, send me email enrique DOT prados AT a-e DOT es


# October 15, 2009 4:47 AM

lkempe said:

alhambraeidos: I am not sure what you wanna do, but NDepend analyze only .NET assemblies

# October 15, 2009 5:04 AM

RhysC said:

Thanks mate, made my life a lot easier

# April 21, 2010 2:40 AM