views:

912

answers:

2

My nant script fails when I run it under cruise-control on (Windows Server 2003), but works fine when run on the console.

nant script (relevant section):

<target name="compile" depends="init">
    <echo message="Build Directory is ${build.dir}" />
    <exec program="${framework::get-framework-directory(framework::get-target-framework())}\msbuild.exe"
          commandline="${solution.file} /m /t:Clean /p:Configuration=${project.config} /v:q" workingdir="." />
    <exec program="${framework::get-framework-directory(framework::get-target-framework())}\msbuild.exe"
          commandline="${solution.file} /m /t:Rebuild /p:Configuration=${project.config} /v:q" workingdir="." />
</target>

cc-config:

<tasks>

    <nant>
        <executable>C:\Program Files\nant-0.86-beta1\bin\nant.exe</executable>
        <baseDirectory>C:\Builds\WorkManagement\RC1</baseDirectory>
        <buildArgs>-D:outputType=Xml</buildArgs>
        <nologo>false</nologo>
        <buildFile>WaterWorks.build</buildFile>
        <targetList>
            <target>build</target>
        </targetList>
        <buildTimeoutSeconds>1200</buildTimeoutSeconds>
    </nant>

</tasks>

This has been working but I think a recent upgrade of nunit (to 2.5.1) has confused things.

cc nant log:

    Buildfile: file:///C:/Builds/WorkManagement/RC1/WaterWorks.build 
    Target framework: Microsoft .NET Framework 3.5 
    Target(s) specified: build 
    [loadtasks] Scanning assembly "NCoverExplorer.NAntTasks" for extensions. 
    [property] Read-only property "outputType" cannot be overwritten. 

    clean: 

    [delete] Deleting directory 'C:\Builds\WorkManagement\RC1\build'. 

    version: 

    init: 

    [tstamp] 15 July 2009 10:31:20. 
    [mkdir] Creating directory 'C:\Builds\WorkManagement\RC1\build\net-3.5.win32-WaterWorksConsole-release\'. 
    [echo] Current Directory: C:\Builds\WorkManagement\RC1 

    drop-database: 

    create-database: 

    compile: 

    [echo] Build Directory is build/net-3.5.win32-WaterWorksConsole-release/ 
    [exec] Microsoft (R) Build Engine Version 3.5.21022.8 
    [exec] [Microsoft .NET Framework, Version 2.0.50727.1433] 
    [exec] Copyright (C) Microsoft Corporation 2007. All rights reserved. 
    [exec] Microsoft (R) Build Engine Version 3.5.21022.8 
    [exec] [Microsoft .NET Framework, Version 2.0.50727.1433] 
    [exec] Copyright (C) Microsoft Corporation 2007. All rights reserved. 
    [exec] C:\WINDOWS\Microsoft.NET\Framework\v3.5\Microsoft.Common.targets : warning MSB3245: Could not resolve this reference. Could not locate the assembly "nunit.framework, Version=2.5.1.9189, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors. 
    [exec] AddressTests.cs(1,7): error CS0246: The type or namespace name 'NUnit' could not be found (are you missing a using directive or an assembly reference?) 
  :
  :

console command to run nant:

nant /f:WaterWorks.build build

Bit mystified! Can anyone point me in the right direction?

+2  A: 

Well, have you installed NUnit version 2.5.1.9189 on the continuous build machine in the GAC? (That exact version.)

Personally I don't like installing dependencies in the GAC anyway - I like to have them explicitly referenced with relative paths, but YMMV.

Jon Skeet
Maybe slightly less critical with unit testing libraries, but certainly agree with Jon for other dependencies.
David M
Thanks Jon but it still fails with the same erro when the nunit.framework.dll is in the GAC. I think I will go for your explicit reference solution
Sam Mackrill
Are you sure that's the *exact* version it's looking for that's in the GAC? I mean it's still a good idea to go with the explicit reference, but it should have worked anyway...
Jon Skeet
nunit.framework 2.5.1.9189 96d09a1eb7f44a77 MSILYep, this is the right one.... the GAC is not something I like to use
Sam Mackrill
Hmm. What does the reference look like in the project file?
Jon Skeet
<Reference Include="nunit.framework, Version=2.5.1.9189, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL" />
Sam Mackrill
Okay, so no hint path there. What happens if you try to reference it from the command line on the same box?
Jon Skeet
like this?C:\Documents and Settings\Administrator.CAM2>"C:\Program Files\NUnit 2.5.1\bin\net-2.0\nunit-console.exe"NUnit version 2.5.1.9189Copyright (C) 2002-2009 Charlie Poole.Copyright (C) 2002-2004 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov.Copyright (C) 2000-2002 Philip Craig.All Rights Reserved.
Sam Mackrill
I was really talking about trying to compile against the framework - try a simple class which just asserts something random.
Jon Skeet
Yes that is the next step, thank Jon, I'll report back when I find (the probably dumb) mistake I made.
Sam Mackrill
A: 

Changing the CruiseControl Windows service account from Local System to Administrator, or some other higher level account, fixed a similar problem we were having. For some reason I haven't figured out yet the Local System account can't access the GAC properly.

Just so you know we are using Apache 2.2 (32-bit), CruiseControl 2.8 (32-bit Java version, not CruiseControl.NET) on Windows Server 2008 R2 (x64). In NAnt we use the Devenv.com to build the solution:

<exec program="Devenv.com" basedir="${compiler.basedir}">
  <arg line='/rebuild "Release" "${solution.file}"' />
</exec>

I know this is an old question but maybe the above will help others with a similar problem.

Chris C