TFS 2010/代码度量集成,自动构建失败,代码度量不运行 [英] TFS 2010/Code Metrics Integration, Automated Builds Fail, Code Metrics Don't Run

查看:15
本文介绍了TFS 2010/代码度量集成,自动构建失败,代码度量不运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在 TFS 2010 中的自动化团队构建之后添加一个自动构建后触发器来运行 NDepend(代码度量软件).

I'm trying to add an automatic post-build trigger to run NDepend (code metrics software) after an automated team build in TFS 2010.

NDepend 的网站提供了用于集成此功能的代码,因此我已将他们的代码粘贴到我的 .csproj 文件中,他们说可以在该文件中使用,但我在构建时收到错误.

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.

错误是指我在代码片段中的三个BuildStep"标签中的两个.以下两个片段给了我错误:

The errors refer to two of the three "BuildStep" tags I have in the code snippet. The following two snippets are giving me errors:

<BuildStep         
    TeamFoundationServerUrl="$(TeamFoundationServerUrl)"
    BuildUri="$(BuildUri)"
    Message="Running NDepend analysis">
  <Output TaskParameter="Id" PropertyName="StepId" />
</BuildStep>

<BuildStep
   TeamFoundationServerUrl="$(TeamFoundationServerUrl)"
   BuildUri="$(BuildUri)"
   Id="$(StepId)"
   Status="Failed" />

然而,这个代码片段并没有引发任何问题:

However, this code snippet is NOT throwing up any problems:

<BuildStep
   TeamFoundationServerUrl="$(TeamFoundationServerUrl)"
   BuildUri="$(BuildUri)"
   Id="$(StepId)"
   Status="Succeeded" />

我只是不明白为什么一个可以正常工作而几乎相同布局的 BuildStep 标签却不能.是否有一些简单的东西我只是忽略了?

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?

以下是它的整体外观,如果这有所不同:

  <Target Name="NDepend"  >
    <PropertyGroup>
      <NDPath>c:	oolsNDependNDepend.console.exe</NDPath>
      <NDProject>$(SolutionDir)MyProject.ndproj</NDProject>
      <NDOut>$(TargetDir)NDepend</NDOut>
      <NDIn>$(TargetDir)</NDIn>
    </PropertyGroup>
    <Exec
      Command='"$(NDPath)" "$(NDProject)" /OutDir "$(NDOut)" /InDirs "$(NDIn)"'/>
  </Target>
  <Target Name="AfterBuild">
    <BuildStep         TeamFoundationServerUrl="$(TeamFoundationServerUrl)"
        BuildUri="$(BuildUri)"
        Message="Running NDepend analysis">
      <Output TaskParameter="Id" PropertyName="StepId" />
    </BuildStep>
    <PropertyGroup>
      <NDPath>c:	oolsNDependNDepend.console.exe</NDPath>
      <NDProject>$(SolutionRoot)MainsrcMyProject.ndproj</NDProject>
      <NDOut>$(BinariesRoot)NDepend</NDOut>
      <NDIn>$(BinariesRoot)Release</NDIn>
    </PropertyGroup>
    <Exec
      Command='$(NDPath) "$(NDProject)" /OutDir "$(NDOut)" /InDirs "$(NDIn)"'/>
    <BuildStep
        TeamFoundationServerUrl="$(TeamFoundationServerUrl)"
        BuildUri="$(BuildUri)"
        Id="$(StepId)"
        Status="Succeeded" />
    <OnError ExecuteTargets="MarkBuildStepAsFailed" />
  </Target>

  <Target Name="MarkBuildStepAsFailed">
    <BuildStep
        TeamFoundationServerUrl="$(TeamFoundationServerUrl)"
        BuildUri="$(BuildUri)"
        Id="$(StepId)"
        Status="Failed" />
  </Target>

添加了赏金,因为我真的需要为我的团队做到这一点.

包含了关于错误的更多细节,出于版权原因,我用blah"伪装了文件的位置/名称,我不确定我在技术上是否能够发布该信息,所以我我在安全方面犯了错误而不是抱歉,但是如果为了解决这个问题你绝对必须知道,我会看看我能做些什么.以下错误列在失败的团队构建的结果中以及各种其他警告中,但这些错误是我能看到的与上述 NDepend XML 代码相关的唯一错误.

运行团队构建时遇到的错误:

The errors I get when I run the team build:

C:*废话*.csproj(172):BuildStep"任务不是成立.检查以下内容: 1.)项目文件中的任务名称与任务名称相同班级.2.) 任务类是public"并实施Microsoft.Build.Framework.ITask界面.3.) 任务正确在声明中项目文件,或在 *.tasks 文件中位于c:WindowsMicrosoft.NETFrameworkv4.0.30319"目录.

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:WindowsMicrosoft.NETFrameworkv4.0.30319" directory.

C:*废话*.csproj(194):BuildStep"任务不是成立.检查以下内容: 1.)项目文件中的任务名称与任务名称相同班级.2.) 任务类是public"并实施Microsoft.Build.Framework.ITask界面.3.) 任务正确在声明中项目文件,或在 *.tasks 文件中位于c:WindowsMicrosoft.NETFrameworkv4.0.30319"目录.

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:WindowsMicrosoft.NETFrameworkv4.0.30319" directory.

我以为我可以正常运行,但它无法正常构建.尽管在下面模仿@Ewald 建议的 XML,但在我构建时它仍然会抛出上面的错误.我根据我认为应该如下工作的方式调整了所述代码的属性值:

  <Target Name="NDepend"  >
    <PropertyGroup>
      <NDPath>c:	oolsNDependNDepend.console.exe</NDPath>
      <NDProject>$(SolutionDir)MyProject.ndproj</NDProject>
      <NDOut>$(TargetDir)NDepend</NDOut>
      <NDIn>$(TargetDir)</NDIn>
    </PropertyGroup>
    <Exec
      Command='"$(NDPath)" "$(NDProject)" /OutDir "$(NDOut)" /InDirs "$(NDIn)"'/>
  </Target>

  <Target Name="AfterBuild">
    <BuildStep         
        TeamFoundationServerUrl="$(TeamFoundationServerUrl)"
        BuildUri="$(BuildUri)"
        Name="CallMyTarget"
        Message="Call My Target"
        Condition="'$(IsDesktopBuild)'!='true'">
      <Output TaskParameter="Id" PropertyName="StepId" />
    </BuildStep>
    <CallTarget Targets="NDepend" ContinueOnError="false"/>
    <BuildStep
        TeamFoundationServerUrl="$(TeamFoundationServerUrl)"
        BuildUri="$(BuildUri)"
        Id="$(StepId)"
        Status="Succeeded"
        Condition="'$(IsDesktopBuild)'!='true'" />
    <OnError ExecuteTargets="FailStep" />
  </Target>

  <Target Name="FailStep">
    <BuildStep
        TeamFoundationServerUrl="$(TeamFoundationServerUrl)"
        BuildUri="$(BuildUri)"
        Id="$(StepId)"
        Status="Failed"
        Condition="'$(IsDesktopBuild)'!='true'" />
  </Target>

但是,我确实尝试将这段代码放入:

  <Target Name="NDepend"  >
    <PropertyGroup>
      <NDPath>c:	oolsNDependNDepend.console.exe</NDPath>
      <NDProject>$(SolutionDir)MyProject.ndproj</NDProject>
      <NDOut>$(TargetDir)NDepend</NDOut>
      <NDIn>$(TargetDir)</NDIn>
    </PropertyGroup>
    <Exec
      Command='"$(NDPath)" "$(NDProject)" /OutDir "$(NDOut)" /InDirs "$(NDIn)"'/>
  </Target>

并且自动构建运行良好,没有错误,但 NDepend 只是没有像预期的那样运行.

我开始怀疑(在咨询了其他各种子问题之后)TFS2010 与 TFS2008 中使用的 XML 模式是否存在一些细微差别,导致我遇到这些问题.那么,考虑到这一点,有人知道这些模式有什么大的不同吗?

只是让大家了解我尝试过的所有内容,我现在尝试了以下代码:

<Target Name="AfterBuild">
    <PropertyGroup>
      <NDPath>c:	oolsNDependNDepend.console.exe</NDPath>
      <NDProject>$(SolutionDir)MyProject.ndproj</NDProject>
      <NDOut>$(TargetDir)NDepend</NDOut>
      <NDIn>$(TargetDir)</NDIn>
    </PropertyGroup>
    <Exec
      Command='"$(NDPath)" "$(NDProject)" /OutDir "$(NDOut)" /InDirs "$(NDIn)"'/>
</Target>

它产生了不同的错误消息,如下所示:

C:*废话*.csproj(179):命令""c: oolsNDependNDepend.console.exe""C:*废话*SourcesMainMyProject.ndproj"/外向"C:*废话*BinariesDebugNDepend"/InDirs"C:*废话*二进制调试""以代码 1 退出.

C:*Blah*.csproj (179): The command ""c: oolsNDependNDepend.console.exe" "C:*Blah*SourcesMainMyProject.ndproj" /OutDir "C:*Blah*BinariesDebugNDepend" /InDirs "C:*Blah*BinariesDebug"" exited with code 1.

我尝试过的最新代码.这是(根据 NDepend 的网站)内置的 NDepend MSBuild 任务".

<Target Name="AfterBuild">
    <PropertyGroup>
        <NDPath>c:	oolsNDependNDepend.console.exe</NDPath>
        <NDProject>$(SolutionDir)MyProject.ndproj</NDProject>
      </PropertyGroup>
      <UsingTask AssemblyFile="$(NDPath)MSBuildNDepend.Build.MSBuild.dll"
             TaskName="NDependTask" />
      <Target Name="NDepend"  >
        <NDependTask NDependConsoleExePath="$(NDPath)"
           ProjectFilePath="$(NDProject)" />
      </Target>
</Target>

但我收到此错误:

C:*Blah*.csproj (180):元素元素下方无法识别.

C:*Blah*.csproj (180): The element beneath element is unrecognized.

推荐答案

我使用以下几行代码来实现额外的构建步骤

I use the following lines of code to achieve additional build steps

<Target Name="Customization">
    <BuildStep TeamFoundationServerUrl="$(TeamFoundationServerUrl)" BuildUri="$(BuildUri)" Name="CallMyTarget" Message="Call my target" Condition="'$(IsDesktopBuild)'!='true'" >
        <Output TaskParameter="Id" PropertyName="CurrentBuildStepId" />
    </BuildStep>

    <CallTarget Targets="MyTarget" ContinueOnError="false"/>

    <BuildStep TeamFoundationServerUrl="$(TeamFoundationServerUrl)" BuildUri="$(BuildUri)" Id="$(CurrentBuildStepId)" Status="Succeeded" Condition="'$(IsDesktopBuild)'!='true'" />

    <OnError ExecuteTargets="FailStep"/>
</Target>

<Target Name="FailStep">
    <BuildStep TeamFoundationServerUrl="$(TeamFoundationServerUrl)" BuildUri="$(BuildUri)" Id="$(CurrentBuildStepId)" Status="Failed" Condition="'$(IsDesktopBuild)'!='true'" />
</Target>

这篇关于TFS 2010/代码度量集成,自动构建失败,代码度量不运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆