CCNET has wrong program files path at runtime

36 Views Asked by At

I am using 1.8.5 of CruiseControl.Net and I am configuring our build scripts for use on x86 and x64 systems. In this script, I define the path value for msbuild.exe file as follows:

<cb:define MSBUILD_PATH="$(PROGRAMFILESFOLDER)\MSBuild\$(VS_MSBUILD_VERSION)\Bin"/>

When I use the CCValidator.exe application to evaluate my configuration the path values are correct:

<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>

When I run my project and this task executes it will use the 64-bit Program Files directory and the task and project fail because the file is not found.

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`

Below is the code for defining the value for PROGRAMFILES and I suspect that the problem is with this section.

<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>

I checked the environment value for ProgramFiles(x86) and it returns the correct value. Can anyone see what I am missing? Thank you.

EDIT: I noticed a couple of things:

<cb:define BUILD_PLATFORM=" ...> syntax is wrong. It should be <cb:define BUILD_PLATFORM="$(ProgramFiles(x86))". When I make this change the validation fails and I cannot start ccnet service. The error is: Preprocessing failed loading the XML: Reference to unknown symbol 'programfiles (x86'. I tried changing the syntax to use the XML and HTML value as well for open and close parenthesis.

1

There are 1 best solutions below

0
Daniel Lee On

I finally worked it out.

  • CCNET cannot process environment variables whose name contains a closing parenthesis. If I create a variable called PROGRAMFILES_X86 and set its value, then it works. That was my solution, therefore each build machine will require this environment variable.
  • I also had a logic error. The conditional should have been == and not != when testing if this is an x86 or x64 system.