【发布时间】:2020-02-23 20:03:38
【问题描述】:
我正在使用 1.8.5 的 CruiseControl.Net,我正在配置我们的构建脚本以在 x86 和 x64 系统上使用。 在这个脚本中,我定义 msbuild.exe 文件的路径值如下:
<cb:define MSBUILD_PATH="$(PROGRAMFILESFOLDER)\MSBuild\$(VS_MSBUILD_VERSION)\Bin"/>
当我使用 CCValidator.exe 应用程序评估我的配置时,路径值是正确的:
<tasks>
<msbuild>
<buildArgs>/p:Configuration=Release /v:quiet</buildArgs>
<description>Clean Developer Updater</description>
<dynamicValues />
<environment />
<executable>C:\Program Files (x86)\MSBuild\14.0\Bin\msbuild.exe</executable>
<logger>"C:\Program Files (x86)\CruiseControl.NET\server\ThoughtWorks.CruiseControl.MSBuild.dll"</logger>
<loggerParameters />
<priority>Normal</priority>
<projectFile>c:\Build\AmazingCharts\working\building\DeveloperUpdater\DeveloperUpdater.sln</projectFile>
<targets>Clean</targets>
<timeout>200</timeout>
<workingDirectory>c:\Build\AmazingCharts\working\building\DeveloperUpdater</workingDirectory>
</msbuild>
</tasks>
当我运行我的项目并执行此任务时,它将使用 64 位 Program Files 目录,并且任务和项目失败,因为找不到该文件。
System.IO.IOException: Unable to execute file [C:\Program Files\MSBuild\14.0\Bin\msbuild.exe].
The file may not exist or may not be executable. (The system cannot find the file specified) --->
System.ComponentModel.Win32Exception: The system cannot find the file specified`
下面是定义 PROGRAMFILES 值的代码,我怀疑这个部分有问题。
<cb:define BUILD_PLATFORM="${ProgramFiles(x86)}"/>
<cb:if expr="'$(BUILD_PLATFORM)'!=''">
<cb:define CURRENT_ENVIRONMENT="x86"/>
<cb:define PROGRAMFILESFOLDER="$(ProgramFiles)"/>
<cb:define NETFRAMEWORK="$(WINDOWS_DIR)\Microsoft.NET\Framework\$(FRAMEWORK_VERSION)"/>
</cb:if>
<cb:else>
<cb:define CURRENT_ENVIRONMENT="x64"/>
<cb:define PROGRAMFILESFOLDER="${ProgramFiles(x86)}"/>
<cb:define PROGRAMFILESX64FOLDER="$(ProgramFiles)"/>
<cb:define NETFRAMEWORK="$(WINDOWS_DIR)\Microsoft.NET\Framework64\$(FRAMEWORK_VERSION)"/>
</cb:else>
我检查了 ProgramFiles(x86) 的环境值,它返回了正确的值。 谁能看到我错过了什么?谢谢你。
编辑: 我注意到了几件事:
<cb:define BUILD_PLATFORM=" ...> 语法错误。应该是<cb:define BUILD_PLATFORM="$(ProgramFiles(x86))"。当我进行此更改时,验证失败并且我无法启动 ccnet 服务。错误是:Preprocessing failed loading the XML: Reference to unknown symbol 'programfiles (x86'.
我尝试更改语法以使用 XML 和 HTML 值以及打开和关闭括号。
【问题讨论】:
-
请注意,如果我对路径进行硬编码,那么任务将正确执行。