Boosting Development Efficiency with CppDepend and TFS Integration

Integrating CppDepend with Team Foundation Server 2008

First create a CppDepend project (.xml or .cdproj) or use an existing one. It should be in source control so you can reference it for TFS.

Adding a MSBuild target to your solution

    Add a post-build task to an existing project, or create a specific msbuild project for CppDepend and add it to the solution to build. The task itself can be either stand-alone:

    <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
      <Target Name="CppDepend"  >
        <PropertyGroup>
          <CppDependPath>c:\tools\CppDepend\CppDepend.console.exe</CppDependPath>
          <CppDependProject>$(SolutionDir)MyProject.cdproj</CppDependProject>
          <CppDependOut>$(TargetDir)CppDepend</CppDependOut>
        </PropertyGroup>
        <Exec
          Command='"$(CppDependPath)" "$(CppDependProject)" /OutDir "$(CppDependOut)" '/>
      </Target>
    </Project>


    Where:

    • CppDependPath: is the path to the CppDepend console executable (you need a valid Build Machine license on the server)
    • CppDependProject: is the path to the CppDepend project
    • CppDependOut: is the path were the reports will be generated

    You can also use the built-in CppDepend MSBuild task:

    <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
        <PropertyGroup>
            <CppDependPath>c:\tools\CppDepend\</CppDependPath>
            <CppDependProject>$(SolutionDir)MyProject.cdproj</CppDependProject>
        </PropertyGroup>
      <UsingTask AssemblyFile="$(CppDependPath)\MSBuild\CppDepend.Build.MSBuild.dll" 
             TaskName="CppDependTask" />
      <Target Name="CppDepend"  >
          <CppDependTask CppDependConsoleExePath="$(CppDependPath)"
             ProjectFilePath="$(CppDependProject)" />
     </Target>
    </Project>


    You can simply add one of these targets to an existing project and add the content of the project element inside the <TargetName="AfterBuild"></Target> element of the project to build.

    Accessing the report files

    Once TFS has built the build project, the CppDepend report will be inside the Drops folder, under the relevant build version.

    Go to top

Integrating CppDepend with Team Foundation Server 2010

Since the TFS build project format has completely changed between TFS 2008 and TFS 2010, the options are slightly different.

    Add the CppDepend target to an existing project

    Using the technique outlined above, override the <TargetName="AfterBuild"></Target> in the vcxproj to automatically run CppDepend in TFS.

    Go to top

CppDepend offers a wide range of features. It is often described as a Swiss Army Knife for C and C++ developers.

Start Free Trial