相关链接在CruiseControl.NET HtmlReportPlugin中不起作用

时间:2012-08-10 21:07:29

标签: iis iis-7 cruisecontrol.net

我在CruiseControl.NET项目的发布者区域中有一个合并任务,它成功地将一组html和png文件复制到artifacts目录。我在仪表板中启用了HtmlReportPlugin,如下所示:

   <buildPlugins>
      <buildReportBuildPlugin>
        <xslFileNames>
          <xslFile>xsl\header.xsl</xslFile>
          <xslFile>xsl\compile.xsl</xslFile>
          <xslFile>xsl\modifications.xsl</xslFile>
          <xslFile>xsl\MsTestSummary2010.xsl</xslFile>
        </xslFileNames>
      </buildReportBuildPlugin>
      <buildLogBuildPlugin />
      <xslReportBuildPlugin description="MSTest2010 Report" actionName="MSTestBuildReport2010" xslFileName="xsl\MsTestReport2010.xsl"></xslReportBuildPlugin>
      <xslReportBuildPlugin description="MSTest Coverage 2010" actionName="MSTestBuildCoverReport2010" xslFileName="xsl\MsTestCover2010.xsl"></xslReportBuildPlugin>
      <htmlReportPlugin description="Html Report" actionName="HtmlReport" htmlFileName="index.html" />
    </buildPlugins>

index.html服务很好,但index.html中的相对链接似乎不起作用。这是index.html的来源:

<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Frameset//EN'
 'http://www.w3.org/TR/html4/frameset.dtd'>
<html><head><title>
all.cov
</title>
<meta http-equiv=Content-Type content='text/html;charset=utf-8'>
</head>
<frameset cols='25%,75%'>
    <frame src=nav-folder.html>
    <frame name=right src=p0.html>
    <noframes>
    <p>Your browser does not support frames. See <a href=nav-folder.html>nav-folder.html</a>
    </noframes>
</frameset>
</html>

这是加载index.html时出现的错误之一(将“nav-folder”替换为“p0”以获取其他错误消息):

  应用程序中的服务器错误。

     

未知对象名称:nav-folder

     

描述:执行期间发生了未处理的异常   当前的网络请求。请查看堆栈跟踪了解更多信息   有关错误的信息以及它在代码中的起源。

     

异常详细信息:System.ApplicationException:未知对象名称:   NAV-夹

     

来源错误:

     

执行期间生成了未处理的异常   当前的网络请求。有关的来源和位置的信息   可以使用下面的异常堆栈跟踪来识别异常。

     

堆栈追踪:

     

[ApplicationException:未知对象名称:nav-folder]
  Objection.ObjectionStore.GetByName(String name)+307
  ThoughtWorks.CruiseControl.WebDashboard.MVC.Cruise.CruiseActionFactory.CreateHandler(字符串   actionName)+231
  ThoughtWorks.CruiseControl.WebDashboard.MVC.Cruise.CruiseActionFactory.Create(IRequest   请求)+38
  ThoughtWorks.CruiseControl.WebDashboard.MVC.RequestController.Do()   +155 ThoughtWorks.CruiseControl.WebDashboard.MVC.ASPNET.HttpHandler.ProcessRequest(HttpContext   上下文)+651
  System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()   +625 System.Web.HttpApplication.ExecuteStep(IExecutionStep step,Boolean&amp; completedSynchronously)+27

如果我在任一参考文件上使用RetrieveBuildFile.aspx(例如,http://localhost/server/local/project/Code_Coverage/build/log20120809181334Lbuild.168.xml/RetrieveBuildFile.aspx?file=p0.html),文件加载没有问题,但在第一个示例中,任何相关文件都将无法加载。

我的CruiseControl.NET web.config中是否有必要让IIS正确解析相关文件路径?我正在使用CruiseControl.NET 1.8.0并运行在Windows 2008上运行的IIS 7,我已经验证了CruiseControl.NET 1.6上出现同样的问题?在Windows 7上运行的IIS上。

3 个答案:

答案 0 :(得分:2)

不幸的是,HTML整理不喜欢Bullseye CodeCoverage HTML,因为它包含无效的HTML。所以这个解决方案不起作用。

CruiseControl使用正则表达式来查找源链接,但这并不完美,因为它错过了HTML属性没有引号并且可以匹配非HTML属性的字符串片段的情况。我已经修改了CruiseControl.NET源代码以使用HtmlAgilityPack来解析HTML,这看起来效果很好(至少在我的测试用例中。)

答案 1 :(得分:1)

如果你需要解决这个问题(不用看你自己CCnet解析html的地方)。我正在使用ReportGenerator和CCnet。这是一个例子:

课堂上:

BuildFileDownload (namespace ThoughtWorks.CruiseControl.WebDashboard.Plugins.BuildReport)

使用以下代码修改执行过程:

HtmlDocument doc = new HtmlDocument();
doc.OptionAddDebuggingAttributes = false;
doc.OptionAutoCloseOnEnd = false;
doc.OptionCheckSyntax = false;
doc.OptionFixNestedTags = false;
doc.OptionOutputOptimizeAttributeValues = false;
doc.LoadHtml(htmlData);

var nodes = doc.DocumentNode.SelectNodes("//a[@href]");
if (nodes != null)
{
    foreach (var link in nodes)
    {
        HtmlAttribute att = link.Attributes["href"];
        if (!att.Value.StartsWith("data:") && !att.Value.StartsWith("#") && !att.Value.StartsWith("http://"))
            att.Value = @"RetrieveBuildFile.aspx?file=coverageReport\" + att.Value;
    }
    htmlData = doc.DocumentNode.WriteTo();
}

nodes = doc.DocumentNode.SelectNodes("//link[@href]");
if (nodes != null)
{
    foreach (var link in nodes)
    {
        HtmlAttribute att = link.Attributes["href"];
        if (!att.Value.StartsWith("data:") && !att.Value.StartsWith("#") && !att.Value.StartsWith("http://"))
            att.Value = @"RetrieveBuildFile.aspx?file=coverageReport\" + att.Value;
    }
    htmlData = doc.DocumentNode.WriteTo();
}

请记住先摆脱旧的regEx解析。它是一个示例代码,但它符合我的所有需求。此解决方案使用HtmlAgilityPack。请注意,作为新属性值的前缀给出的路径可能不同。

答案 2 :(得分:0)

问题在于CruiseControl.NET不喜欢具有未引用值的属性的HTML。我正在使用Bullseye CodeCoverage生成的输出,并且该输出具有未引用的值的属性。我正在使用HTML Tidy添加引号。

相关问题