向项目节点添加xmlns时,CruiseControl“检测到未使用的节点”错误

时间:2011-07-14 19:06:54

标签: .net configuration cruisecontrol.net nant

我正在尝试使用Cruise Control preprocessor functionality将我的配置分解为更小的可重用部分。我可以在root cruisecontrol节点中使用include功能,如下所示:

<cruisecontrol xmlns:cb="urn:ccnet.config.builder">
    <cb:include href="child.config" />
</cruisecontrol>

如果我尝试在子配置中使用另一个include(如此):

<project name="TestProject" xmlns:cb="urn:ccnet.config.builder">    
    <cb:include href="grandchild.config" />
</project>

我收到以下错误:

  

ThoughtWorks.CruiseControl.Core.Config.ConfigurationException:检测到未使用的节点:xmlns:cb =“urn:ccnet.config.builder”

如果我删除xmlns名称空间语句,我会收到此错误:

  

ThoughtWorks.CruiseControl.Core.Config.ConfigurationException:配置文件包含无效的xml:E:\ Build \ Config \ AppRiver.Tools.BuildAutomation \ CruiseControl \ ccnet.config ---&gt; System.Xml.XmlException:'cb'是未声明的命名空间。

最后,如果我删除标签上的“cb”前缀,我会收到此错误

Unused node detected:     Unused node detected: <define buildFile="CP.WEB.Dev.SanityCheck.CI.build" />

我没有想法 - 任何帮助表示赞赏!

4 个答案:

答案 0 :(得分:5)

要使用<cb:include><cb:include>标记必须定义xml名称空间,并且包含的​​文件必须以其中定义了xml名称空间的元素开头。这是在文档中,但很容易错过。

<cruisecontrol xmlns:cb="urn:ccnet.config.builder">
  <cb:include href="projectFile.xml" xmlns:cb="urn:ccnet.config.builder"/>
</cruisecontrol>

projectFile.xml

<cb:config-template xmlns:cb="urn:ccnet.config.builder">
  <project>
      ...
  </project>
</cb:config-template>

此外,如果您要添加注释here的ccnet版本信息,则还需要在包含的文件中包含该命名空间。

所以ccnet.config看起来像:

<cruisecontrol xmlns:cb="urn:ccnet.config.builder" xmlns="http://thoughtworks.org/ccnet/1/8">
  <cb:include href="projectFile.xml" xmlns:cb="urn:ccnet.config.builder"/>
</cruisecontrol>

和projectFile.xml更改为

<cb:config-template xmlns:cb="urn:ccnet.config.builder" xmlns="http://thoughtworks.org/ccnet/1/8">
  <project>
      ...
  </project>
</cb:config-template>

答案 1 :(得分:2)

这不一定是您包含文件的方式的问题。这是一个更通用的错误。我在源控制语句中意外遗漏了一个标记时遇到了这个问题。

我认为它用于表示您插入的xml并未被您尝试在其中使用的元素理解

我偶然发现了这个(适用于多源控制):

<cb:define name="Hg">
    <repo>$(repo)</repo>
    <executable>$(hgExePath)</executable>
    <branch>default</branch>
    <workingDirectory>$(dir)</workingDirectory>
</cb:define>

用于这样的事情:

<cb:define name="SourceControl">
    <sourcecontrol type="hg">
        <cb:Hg repo="$(repo)" dir="." />
    </sourcecontrol>
</cb:define>

因为sourcecontrol(原生的ccnet)已经指定了type =&#34; hg&#34;它不期望看到hg元素

答案 2 :(得分:1)

尝试从Project标记中删除包含的孙。此外,我们在Include标记中包含xmlns:cb =“urn:ccnet.config.builder”。

<cb:include href="grandchild.config" xmlns:cb="urn:ccnet.config.builder"/>

答案 3 :(得分:1)

如果在项目标记上放置了xmlns,则Cruise Control会抛出错误。这似乎是一个错误。我现在已经离开Cruise Control并进入Hudson,对此非常满意。

相关问题