Note that there are some explanatory texts on larger screens.

plurals
  1. POTFS 2010/Code Metrics Integration, Automated Builds Fail, Code Metrics Don't Run
    text
    copied!<p>I'm trying to add an automatic post-build trigger to run NDepend (code metrics software) after an automated team build in TFS 2010.</p> <p>NDepend's website provided code for integrating this capability, and so I have pasted their code into my .csproj file where they said for it to go, but I receive errors on the build.</p> <p>The errors refer to two of the three "BuildStep" tags I have in the code snippet. The following two snippets are giving me errors:</p> <pre><code>&lt;BuildStep TeamFoundationServerUrl="$(TeamFoundationServerUrl)" BuildUri="$(BuildUri)" Message="Running NDepend analysis"&gt; &lt;Output TaskParameter="Id" PropertyName="StepId" /&gt; &lt;/BuildStep&gt; </code></pre> <p>and</p> <pre><code>&lt;BuildStep TeamFoundationServerUrl="$(TeamFoundationServerUrl)" BuildUri="$(BuildUri)" Id="$(StepId)" Status="Failed" /&gt; </code></pre> <p>However, this code snippet is NOT throwing up any problems:</p> <pre><code>&lt;BuildStep TeamFoundationServerUrl="$(TeamFoundationServerUrl)" BuildUri="$(BuildUri)" Id="$(StepId)" Status="Succeeded" /&gt; </code></pre> <p>I just don't understand why one works fine and a nearly identically laid out BuildStep tag does not. Is there something simple that I'm just overlooking?</p> <p><strong>EDIT: Here is how it looks all together, if this makes a difference:</strong></p> <pre><code> &lt;Target Name="NDepend" &gt; &lt;PropertyGroup&gt; &lt;NDPath&gt;c:\tools\NDepend\NDepend.console.exe&lt;/NDPath&gt; &lt;NDProject&gt;$(SolutionDir)MyProject.ndproj&lt;/NDProject&gt; &lt;NDOut&gt;$(TargetDir)NDepend&lt;/NDOut&gt; &lt;NDIn&gt;$(TargetDir)&lt;/NDIn&gt; &lt;/PropertyGroup&gt; &lt;Exec Command='"$(NDPath)" "$(NDProject)" /OutDir "$(NDOut)" /InDirs "$(NDIn)"'/&gt; &lt;/Target&gt; &lt;Target Name="AfterBuild"&gt; &lt;BuildStep TeamFoundationServerUrl="$(TeamFoundationServerUrl)" BuildUri="$(BuildUri)" Message="Running NDepend analysis"&gt; &lt;Output TaskParameter="Id" PropertyName="StepId" /&gt; &lt;/BuildStep&gt; &lt;PropertyGroup&gt; &lt;NDPath&gt;c:\tools\NDepend\NDepend.console.exe&lt;/NDPath&gt; &lt;NDProject&gt;$(SolutionRoot)\Main\src\MyProject.ndproj&lt;/NDProject&gt; &lt;NDOut&gt;$(BinariesRoot)\NDepend&lt;/NDOut&gt; &lt;NDIn&gt;$(BinariesRoot)\Release&lt;/NDIn&gt; &lt;/PropertyGroup&gt; &lt;Exec Command='$(NDPath) "$(NDProject)" /OutDir "$(NDOut)" /InDirs "$(NDIn)"'/&gt; &lt;BuildStep TeamFoundationServerUrl="$(TeamFoundationServerUrl)" BuildUri="$(BuildUri)" Id="$(StepId)" Status="Succeeded" /&gt; &lt;OnError ExecuteTargets="MarkBuildStepAsFailed" /&gt; &lt;/Target&gt; &lt;Target Name="MarkBuildStepAsFailed"&gt; &lt;BuildStep TeamFoundationServerUrl="$(TeamFoundationServerUrl)" BuildUri="$(BuildUri)" Id="$(StepId)" Status="Failed" /&gt; &lt;/Target&gt; </code></pre> <p><strong>EDIT: Added a bounty because I really need to get this going for my team.</strong></p> <p><strong>EDIT: Included more specifics about the errors, I disguised the location/name of the file by "blah" for copyright reasons, I'm not sure if I'm technically able to release that info, so I am erring on the side of safe rather than sorry, but if you absolutely must know for the sake of fixing this problem, I'll see what I can do. The following errors were listed in the results of the failed team build as well as various other warnings, but these errors were the only ones that I could see that pertained to the NDepend XML code above.</strong></p> <p>The errors I get when I run the team build:</p> <blockquote> <p>C:*Blah*.csproj (172): The "BuildStep" task was not found. Check the following: 1.) The name of the task in the project file is the same as the name of the task class. 2.) The task class is "public" and implements the Microsoft.Build.Framework.ITask interface. 3.) The task is correctly declared with in the project file, or in the *.tasks files located in the "c:\Windows\Microsoft.NET\Framework\v4.0.30319" directory.</p> </blockquote> <p>and</p> <blockquote> <p>C:*Blah*.csproj (194): The "BuildStep" task was not found. Check the following: 1.) The name of the task in the project file is the same as the name of the task class. 2.) The task class is "public" and implements the Microsoft.Build.Framework.ITask interface. 3.) The task is correctly declared with in the project file, or in the *.tasks files located in the "c:\Windows\Microsoft.NET\Framework\v4.0.30319" directory.</p> </blockquote> <p><strong>EDIT: I thought I had it running right, but it sill isn't building properly. It's still throwing up the errors above when I build, despite mimicking @Ewald's suggested XML below. I adjusted the property values of said code according to what I think should work as follows:</strong></p> <pre><code> &lt;Target Name="NDepend" &gt; &lt;PropertyGroup&gt; &lt;NDPath&gt;c:\tools\NDepend\NDepend.console.exe&lt;/NDPath&gt; &lt;NDProject&gt;$(SolutionDir)MyProject.ndproj&lt;/NDProject&gt; &lt;NDOut&gt;$(TargetDir)NDepend&lt;/NDOut&gt; &lt;NDIn&gt;$(TargetDir)&lt;/NDIn&gt; &lt;/PropertyGroup&gt; &lt;Exec Command='"$(NDPath)" "$(NDProject)" /OutDir "$(NDOut)" /InDirs "$(NDIn)"'/&gt; &lt;/Target&gt; &lt;Target Name="AfterBuild"&gt; &lt;BuildStep TeamFoundationServerUrl="$(TeamFoundationServerUrl)" BuildUri="$(BuildUri)" Name="CallMyTarget" Message="Call My Target" Condition="'$(IsDesktopBuild)'!='true'"&gt; &lt;Output TaskParameter="Id" PropertyName="StepId" /&gt; &lt;/BuildStep&gt; &lt;CallTarget Targets="NDepend" ContinueOnError="false"/&gt; &lt;BuildStep TeamFoundationServerUrl="$(TeamFoundationServerUrl)" BuildUri="$(BuildUri)" Id="$(StepId)" Status="Succeeded" Condition="'$(IsDesktopBuild)'!='true'" /&gt; &lt;OnError ExecuteTargets="FailStep" /&gt; &lt;/Target&gt; &lt;Target Name="FailStep"&gt; &lt;BuildStep TeamFoundationServerUrl="$(TeamFoundationServerUrl)" BuildUri="$(BuildUri)" Id="$(StepId)" Status="Failed" Condition="'$(IsDesktopBuild)'!='true'" /&gt; &lt;/Target&gt; </code></pre> <p><strong>However, I did try just putting this code in:</strong></p> <pre><code> &lt;Target Name="NDepend" &gt; &lt;PropertyGroup&gt; &lt;NDPath&gt;c:\tools\NDepend\NDepend.console.exe&lt;/NDPath&gt; &lt;NDProject&gt;$(SolutionDir)MyProject.ndproj&lt;/NDProject&gt; &lt;NDOut&gt;$(TargetDir)NDepend&lt;/NDOut&gt; &lt;NDIn&gt;$(TargetDir)&lt;/NDIn&gt; &lt;/PropertyGroup&gt; &lt;Exec Command='"$(NDPath)" "$(NDProject)" /OutDir "$(NDOut)" /InDirs "$(NDIn)"'/&gt; &lt;/Target&gt; </code></pre> <p><strong>And the automated build went fine, no errors, but the NDepend just didn't run like it was supposed to.</strong></p> <p><strong>I'm beginning to wonder (after consultation with various other sub-questions) if there's some slight difference in the XML schema used in TFS2010 vs TFS2008 that is causing me to have these problems. So, with that in mind, does anyone know about any big differences in these schemas?</strong></p> <p><strong>EDIT: Just keeping you all up to date with everything I've tried, I now tried this code:</strong></p> <pre><code>&lt;Target Name="AfterBuild"&gt; &lt;PropertyGroup&gt; &lt;NDPath&gt;c:\tools\NDepend\NDepend.console.exe&lt;/NDPath&gt; &lt;NDProject&gt;$(SolutionDir)MyProject.ndproj&lt;/NDProject&gt; &lt;NDOut&gt;$(TargetDir)NDepend&lt;/NDOut&gt; &lt;NDIn&gt;$(TargetDir)&lt;/NDIn&gt; &lt;/PropertyGroup&gt; &lt;Exec Command='"$(NDPath)" "$(NDProject)" /OutDir "$(NDOut)" /InDirs "$(NDIn)"'/&gt; &lt;/Target&gt; </code></pre> <p><strong>and it produced a different error message, as follows:</strong></p> <blockquote> <p>C:*Blah*.csproj (179): The command ""c:\tools\NDepend\NDepend.console.exe" "C:*Blah*\Sources\Main\MyProject.ndproj" /OutDir "C:*Blah*\Binaries\Debug\NDepend" /InDirs "C:*Blah*\Binaries\Debug\"" exited with code 1.</p> </blockquote> <p><strong>EDIT: The latest code I tried. This was (according to NDepend's site) the "built-in NDepend MSBuild task."</strong></p> <pre><code>&lt;Target Name="AfterBuild"&gt; &lt;PropertyGroup&gt; &lt;NDPath&gt;c:\tools\NDepend\NDepend.console.exe&lt;/NDPath&gt; &lt;NDProject&gt;$(SolutionDir)MyProject.ndproj&lt;/NDProject&gt; &lt;/PropertyGroup&gt; &lt;UsingTask AssemblyFile="$(NDPath)\MSBuild\NDepend.Build.MSBuild.dll" TaskName="NDependTask" /&gt; &lt;Target Name="NDepend" &gt; &lt;NDependTask NDependConsoleExePath="$(NDPath)" ProjectFilePath="$(NDProject)" /&gt; &lt;/Target&gt; &lt;/Target&gt; </code></pre> <p>But I get this error:</p> <blockquote> <p>C:*Blah*.csproj (180): The element beneath element is unrecognized.</p> </blockquote>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload