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
- Continuous Integration - running compilation, unit testing, code coverage and deployment on staging
- Nightly build - to find duplicates in the code
- 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
- 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
- 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:
Then I define a Target for NDepend:
<Target Name=”NDepend“>
<Message Text=”#——— Executing NDepend ———#“ />
<NDependTask 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:
<Target Name=”AfterBuild“>
<CallTarget Condition=” ‘$(Configuration)’ == ‘Staging’ “ Targets=”SummaryCoverage“ ContinueOnError=”false“ />
<CallTarget Condition=” ‘$(Configuration)’ == ‘Nightly’ “ Targets=”FullCoverage“ ContinueOnError=”false“ />
<CallTarget 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!