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

查看:155
本文介绍了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?

编辑:这是简单的事情吗? / p>

Here is how it looks all together, if this makes a difference:

  <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>

编辑:添加了赏金,因为我真的需要为我的团队做这件事。 / strong>

Added a bounty because I really need to get this going for my team.

编辑:包含有关错误的更多详细信息,出于版权原因,我用 blah掩盖了文件的位置/名称,不知道我是否能够在技术上发布该信息,所以我出于安全考虑而不是后悔,但是如果您绝对必须知道为解决此问题,我会做些什么。在失败的团队构建结果以及其他各种警告中列出了以下错误,但是这些错误是我所看到的唯一与上面的NDepend XML代码有关的错误。

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

The errors I get when I run the team build:


C:* Blah * .csproj
(172):找不到
BuildStep任务。检查以下内容:1.)项目文件
中任务的
名称与任务
类的名称相同。 2.)任务类是公共
,并实现
Microsoft.Build.Framework.ITask
接口。 3.)正确地在
项目文件或
c:\Windows\Microsoft中的* .tasks文件
中声明了
。 NET\Framework\v4.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:\Windows\Microsoft.NET\Framework\v4.0.30319" directory.


C:* Blah * .csproj
(194):未找到
BuildStep任务。检查以下内容:1.)项目文件
中任务的
名称与任务
类的名称相同。 2.)任务类是公共
,并实现
Microsoft.Build.Framework.ITask
接口。 3.)正确地在
项目文件或
c:\Windows\Microsoft中的* .tasks文件
中声明了
。 NET\Framework\v4.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:\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):命令
c:\tools\NDepend DependNDepend.console.exe
C:* Blah * \Sources\Main\MyProject.ndproj
/ OutDir
C:* Blah * \Binaries\ \Debug\NDepend
/ InDirs
C:* Blah * \Binaries\Debug\
以代码1退出。

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):无法识别元素
下的元素

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天全站免登陆