CC.NET配置预处理器条件语句和Windows环境

时间:2013-11-17 19:44:23

标签: cruisecontrol.net

CruiseControl.NET的配置预处理器不像我期望的那样读取我的Windows环境。这是一个简单的ccnet.config来演示这个问题:

    <cruisecontrol xmlns:cb="urn:ccnet.config.builder" xmlns="http://thoughtworks.org/ccnet/1/8">
        <cb:if expr="'$(PROCESSOR_ARCHITECTURE)' == 'x86'">
            <cb:define devenvExecutable="C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\devenv.com" />
        </cb:if>
        <cb:else>
            <cb:define devenvExecutable="C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\devenv.com" />
        </cb:else>

        <project name="test1" >
            <tasks>
                <dumpValue>
                    <xmlFileName>somefile.xml</xmlFileName>
                    <dumpValueItems>
                        <dumpValueItem name="PROCESSOR_ARCHITECTURE" value="$(PROCESSOR_ARCHITECTURE)" />
                        <dumpValueItem name="devenvExecutable" value="$(devenvExecutable)" />
                    </dumpValueItems>
                </dumpValue>
            </tasks>
        </project>
    </cruisecontrol>

当我在运行Windows 7 64位且环境变量PROCESSOR_ARCHITECTURE = AMD64的计算机上的CCValidator中打开上述文件时,在CCValidator的“已处理”输出选项卡中显示:

<tasks>
  <dumpValue>
    <dynamicValues />
    <environment />
    <dumpValueItems>
      <dumpValueItem>
        <name>PROCESSOR_ARCHITECTURE</name>
        <value>x86</value>
        <valueInCDATA>True</valueInCDATA>
      </dumpValueItem>
      <dumpValueItem>
        <name>devenvExecutable</name>
        <value>C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\devenv.com</value>
        <valueInCDATA>True</valueInCDATA>
      </dumpValueItem>
    </dumpValueItems>
    <xmlFileName>somefile.xml</xmlFileName>
  </dumpValue>
</tasks>

我期望PROCESSOR_ARCHITECTURE显示为AMD64,因此devenvExecutable显示为使用(x86)路径。为什么不正确读取我的Windows环境?谢谢你的帮助。

1 个答案:

答案 0 :(得分:0)

非常感谢Olivier Sannier在cruisecontrolnet.org帮助论坛上回答这个问题。在这里发布答案是为了完整性。由于CC.Net是一个32位进程,它在64位O / S下在WOW下运行;在WOW中,PROCESSOR_ARCHITECTURE环境变量值为“x86”。我使用了PROCESSOR_IDENTIFIER环境变量来解决问题:

<cb:if expr="'$(PROCESSOR_IDENTIFIER)'.Contains(&quot;x86&quot;)">
   <cb:define devenvExecutable="C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\devenv.com" />
</cb:if>
<cb:else>
   <cb:define devenvExecutable="C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\devenv.com" />
</cb:else>

CC.NET帮助论坛上的线程链接是here