65.9K
CodeProject 正在变化。 阅读更多。
Home

设置 CCNet 的 Web 仪表板以显示 MSBuild 文件的编译器错误

starIconstarIconstarIconstarIcon
emptyStarIcon
starIcon

4.82/5 (10投票s)

2010 年 4 月 7 日

CPOL

2分钟阅读

viewsIcon

31273

本教程将解释如何设置 CCNet 以显示 MSBuild 的编译器错误

引言

在本教程中,我将解释如何设置 Web 仪表板以显示 MSBuild 错误。

背景

在上一篇文章中,我解释了如何设置 MSbuild 文件和 CCNet 以自动构建项目。 在本部分中,我将解释如何配置 ccnet 的 Web 仪表板以显示 msbuild 错误。

Using the Code

默认情况下,ccnet 的 Web 仪表板会显示构建结果,但不显示确切的错误消息。 要在 Web 仪表板中显示错误,请转到“C:\Program Files\CruiseControl.NET\webdashboard”并打开文件 dashboard.config

在那里,您会找到以下代码

<buildReportBuildPlugin>
	<xslFileNames>
		<xslFile>xsl\header.xsl</xslFile>
		<xslFile>xsl\modifications.xsl</xslFile>
		<xslFile>xsl\unittests.xsl</xslFile>
		<xslFile>xsl\MsTestSummary.xsl</xslFile>
		<xslFile>xsl\fxcop-summary.xsl</xslFile>
		<xslFile>xsl\NCoverSummary.xsl</xslFile>
		<xslFile>xsl\SimianSummary.xsl</xslFile>
		<xslFile>xsl\fitnesse.xsl</xslFile>
	</xslFileNames>
</buildReportBuildPlugin>

现在在上面的代码中添加以下行

<xslFile>xsl\compile-msbuild.xsl</xslFile> 

因此代码将变成

<buildReportBuildPlugin>
	<xslFileNames>
		<xslFile>xsl\header.xsl</xslFile>
		<xslFile>xsl\modifications.xsl</xslFile>
		<xslFile>xsl\compile-msbuild.xsl</xslFile>
		<xslFile>xsl\unittests.xsl</xslFile>
		<xslFile>xsl\MsTestSummary.xsl</xslFile>
		<xslFile>xsl\fxcop-summary.xsl</xslFile>
		<xslFile>xsl\NCoverSummary.xsl</xslFile>
		<xslFile>xsl\SimianSummary.xsl</xslFile>
		<xslFile>xsl\fitnesse.xsl</xslFile>
	</xslFileNames>
</buildReportBuildPlugin> 

我们就完成了。

1.JPG

关注点

在 ccnet 的 Web 仪表板文件夹中有很多 XSL 文件可用。 我们可以根据我们的要求对其进行调整。

在构建失败时向用户组发送电子邮件

如果构建失败,我们还可以向用户组发送电子邮件。

<workingDirectory>D:\Projects\TheWorks\Applications\ProjectFolder</workingDirectory>
       <buildArgs>ProjectName.msbuild /p:Configuration=Debug</buildArgs>
		<timeout>1800</timeout>
		<!--  30 minutes -->
<logger>C:\Program Files\CruiseControl.NET\server\ThoughtWorks.CruiseControl.MSBuild.dll
</logger>
		</msbuild>
		</tasks>
		<publishers>
			<statistics />
			<xmllogger />
			<email from="EMAIL ADDRESS" mailhost="HOSTNAME" 
			mailhostPassword="PASSWORD" mailhostUsername="USERNAME" 
			includeDetails="true">
				<users>
				<user name="Jitendra Zaa" 
					address=ilovenagpur@gmail.com 
					group="AdminGroup" />
					<user name="Santosh Karemore" 
					address=santosh.karemore@gmail.com 
					group="AdminGroup" />
					<user name="Manoranjan sahoo"
					address=manoranjan.sahoo@gmail.com 
					group="AdminGroup" />
					<user name="Minal Shirsikar" 
					address="admin@shivasoft.in" group="Emul" />
				</users>
				<groups>
					<group name="Emul" notification="failed" />
					<group name="AdminGroup" 
						notification="failed" />
				</groups>
			</email>
		</publishers>
	</project>  

这些标签是不言自明的。

可能有以下类型的通知

  • 失败
  • 固定
  • Always

我们可以根据需要创建任意数量的组,并且可以为每个组指定通知类型。

注意

在配置文件中编写统计数据和 xmllogger 非常重要,否则它会在 Web 仪表板中报错。

更改发送的电子邮件格式

默认情况下,CCnet 发送的电子邮件不包含错误原因。 我们可以更改发送的电子邮件格式。

打开“ccnet.exe.config”和“ccservice.exe.config”文件

并更改以下行以在电子邮件中获取错误。

<!-- Specifies the stylesheets that are used to 
transform the build results when using the EmailPublisher -->
	<xslFiles>
		<file name="xsl\header.xsl"/>
		<file name="xsl\compile.xsl"/>
                <file name="xsl\compile-msbuild.xsl"/>
		<file name="xsl\unittests.xsl"/>
		<file name="xsl\fit.xsl"/>
		<file name="xsl\modifications.xsl"/>
		<file name="xsl\fxcop-summary.xsl"/>
	</xslFiles> 

以下是 XSL 文件列表及其工作原理

转换名称 描述
header 构建的摘要信息,包括是否通过或失败
compile 显示在编译 .NET 项目期间遇到的任何错误或警告
unittests 显示构建日志中遇到的任何 NUnit 或 JUnit 输出的摘要信息
modifications 显示此构建中首次遇到的对源代码管理的任何更改
fxcop-summary 遇到的任何 FxCop 输出的摘要信息。 适用于 FxCop 1.312 生成的输出
fit 打印构建日志中遇到的任何 Fit 输出的摘要信息
tests 详细的 NUnit 报告
AlternativeNUnitDetails 另一种 NUnit 报告
timing 详细的 NUnit 计时报告
Nant 以控制台窗口中显示的方式显示任何 NAnt 输出
FxCopReport 遇到的任何 FxCop 输出的详细信息。 适用于 FxCop 1.312 生成的输出。 有关更多详细信息,请参见此处
NCover NCover 输出的报告。 适用于 NCover 的 NCover.Org 版本。 有关更多详细信息,请参见此处
vil Vil Metrics 的报告。 有关更多详细信息,请参见此处
msbuild.xsl 使用 MSBuild 时的详细构建报告
compile-msbuild.xsl 显示在使用 MSBuild 编译 .NET 项目期间遇到的任何错误或警告

历史

  • 2010 年 4 月 7 日:初始发布
© . All rights reserved.