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

前端之家收集整理的这篇文章主要介绍了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>
原文链接:https://www.f2er.com/xml/292726.html

猜你在找的XML相关文章