xml – TFS 2010 /代码度量标准集成,自动构建失败,代码度量标准不运行

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

NDepend的网站提供了集成此功能的代码,因此我将他们的代码粘贴到我们的.csproj文件中,他们说它要去,但是我在构建时收到错误.

错误是指我在代码片段中的三个“BuildStep”标记中的两个.以下两个片段给我错误:

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

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

但是,此代码段不会引发任何问题:

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

我只是不明白为什么一个工作正常,几乎相同布局的BuildStep标签没有.有什么简单的东西我只是俯瞰吗?

编辑:这是它如何看起来如何,如果这有所不同:

<Target Name="NDepend"  >
    <PropertyGroup>
      <NDPath>c:\tools\NDepend\NDepend.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:\tools\NDepend\NDepend.console.exe</NDPath>
      <NDProject>$(SolutionRoot)\Main\src\MyProject.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代码有关的唯一错误.

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

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.

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.

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

<Target Name="NDepend"  >
    <PropertyGroup>
      <NDPath>c:\tools\NDepend\NDepend.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:\tools\NDepend\NDepend.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:\tools\NDepend\NDepend.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:*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.

编辑:我试过的最新代码.这是(根据NDepend的网站)“内置的NDepend MSBuild任务”.

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

但我得到这个错误:

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

我使用以下代码行来实现其他构建步骤
<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>

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


php输出xml格式字符串
J2ME Mobile 3D入门教程系列文章之一
XML轻松学习手册
XML入门的常见问题(一)
XML入门的常见问题(三)
XML轻松学习手册(2)XML概念
xml文件介绍及使用
xml编程(一)-xml语法
XML文件结构和基本语法
第2章 包装类
XML入门的常见问题(二)
Java对象的强、软、弱和虚引用
JS解析XML文件和XML字符串详解
java中枚举的详细使用介绍
了解Xml格式
XML入门的常见问题(四)
深入SQLite多线程的使用总结详解
PlayFramework完整实现一个APP(一)
XML和YAML的使用方法
XML轻松学习总节篇