Integrate CppDepend with TFS

Integrate CppDepend with TFS



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.