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):“BuildStep”任务不是 成立。检查以下内容: 1.) 项目文件中的任务名称 与任务名称相同 班级。 2.) 任务类别是“公共” 并实施 Microsoft.Build.Framework.ITask 界面。 3.) 任务正确 声明与在 项目文件,或 *.tasks 文件中 位于 “c:\Windows\Microsoft.NET\Framework\v4.0.30319” 目录。
和
C:*Blah*.csproj (194):“BuildStep”任务不是 成立。检查以下内容: 1.) 项目文件中的任务名称 与任务名称相同 班级。 2.) 任务类别是“公共” 并实施 Microsoft.Build.Framework.ITask 界面。 3.) 任务正确 声明与在 项目文件,或 *.tasks 文件中 位于 “c:\Windows\Microsoft.NET\Framework\v4.0.30319” 目录。
编辑:我以为我运行正确,但它仍然无法正常构建。尽管模仿了@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 只是没有像预期那样运行。
我开始想知道(在咨询了各种其他子问题之后)所使用的 XML 模式是否存在一些细微的差异在 TFS2010 与 TFS2008 中,这导致我遇到这些问题。那么,考虑到这一点,有人知道这些模式有什么大的差异吗?
编辑:为了让大家了解我尝试过的所有内容,我现在尝试了以下代码: >
<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\NDepend.console.exe" “C:*Blah*\Sources\Main\MyProject.ndproj” /输出目录 “C:*Blah*\Binaries\Debug\NDepend” /在目录中 “C:*Blah*\Binaries\Debug\”” 退出并显示代码 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):元素 元素下方 无法识别。
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'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.
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>
and
<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" />
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?
EDIT: 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>
EDIT: Added a bounty because I really need to get this going for my team.
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.
The errors I get when I run the team build:
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.
and
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.
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:
<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>
However, I did try just putting this code in:
<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>
And the automated build went fine, no errors, but the NDepend just didn't run like it was supposed to.
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?
EDIT: Just keeping you all up to date with everything I've tried, I now tried this code:
<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>
and it produced a different error message, as follows:
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.
EDIT: The latest code I tried. This was (according to NDepend's site) the "built-in NDepend MSBuild task."
<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>
But I get this error:
C:*Blah*.csproj (180): The element
beneath element
is unrecognized.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我使用以下代码行来实现额外的构建步骤
I use the following lines of code to achieve additional build steps
这些代码片段仅在您运行 Team Build 时才有效。当您运行桌面构建时它们可能会失败。您可以安全地删除这些行,因为如果您使用的是 Team Buid,它们所做的只是在构建日志中添加一行。
The code snippets only work when you run Team Build. They will probably fail when you run a desktop build. You can safely remove these lines because all they do is adding a line the build log if you are using Team Buid.