views:

699

answers:

3

I have a simple HelloWorld application that I'm trying to build using NAnt. However, even with the simplest of build files, I still cannot get it to work. Below is my HelloWorld.build file.

<?xml version="1.0"?>
<project name="Hello World" default="build">
<property name="nant.settings.currentframework" value="net-3.5"/>
<target name="build">
    <echo>Hello</echo>
 <exec program="${framework::get-framework-directory(framework::get-target-framework())}\msbuild.exe"         
  commandline="HelloWorld /t:Clean /p:Configuration=Debug /v:q" workingdir="." /> 
</target>

Here are the results.

C:\webdev\HelloWorld>c:\nant-0.86-beta1\bin\NAnt.exe build
NAnt 0.86 (Build 0.86.2898.0; beta1; 12/8/2007)
Copyright (C) 2001-2007 Gerry Shaw
http://nant.sourceforge.net

Buildfile: file:///C:/webdev/HelloWorld/HelloWorld.build
Target framework: Microsoft .NET Framework 2.0
Target(s) specified: build

 [property] Target framework changed to "Microsoft .NET Framework 3.5".

BUILD FAILED

INTERNAL ERROR

System.NullReferenceException: Object reference not set to an instance of an object.
   at NAnt.Core.FrameworkInfo.get_Version()
   at NAnt.Core.Project.UpdateTargetFrameworkProperties()
   at NAnt.Core.Tasks.PropertyTask.ExecuteTask()
   at NAnt.Core.Task.Execute()
   at NAnt.Core.Project.InitializeProjectDocument(XmlDocument doc)
   at NAnt.Core.Project.Execute()
   at NAnt.Core.Project.Run()

Please send bug report to [email protected].

Total time: 0 seconds.

Also, when I try to manually set the .NET framework to use, I get the following:

C:\webdev\HelloWorld>c:\nant-0.86-beta1\bin\NAnt.exe -t:net-3.5
NAnt 0.86 (Build 0.86.2898.0; beta1; 12/8/2007)
Copyright (C) 2001-2007 Gerry Shaw
http://nant.sourceforge.net

Microsoft .NET Framework 3.5 (net-3.5) is not installed, or not correctly configured.

    Object reference not set to an instance of an object.

However, the config file does have an entry for .NET 3.5 .This is with NAnt-0.86-beta and Visual C# 2008 Express Edition. Am I completely off track? If so, does anyone perhaps have a template build file that can be reused?

Thank you.

+2  A: 

Well I tried your build file on a very simple console application and aside from tweaking the command line arguments it all works just fine for me.

Have you tried to reinstall the .net framework 3.5 as it definately looks like thats missing (what happens if you try and execute msbuild from the cmd line with the exact path from the 3.5 framework directory ?)

<?xml version="1.0"?>
<project name="HelloWorld" default="build">
    <property name="nant.settings.currentframework" value="net-3.5"/>
    <target name="build">    
     <echo>Hello</echo>       
     <exec program="${framework::get-framework-directory(framework::get-target-framework())}\msbuild.exe" commandline="HelloWorld.sln /t:Clean /p:Configuration=Debug /v:q" workingdir="." />
    </target>
</project>

the output for my project looks like this

NAnt 0.86 (Build 0.86.2898.0; beta1; 08/12/2007)
Copyright (C) 2001-2007 Gerry Shaw
http://nant.sourceforge.net

Buildfile: file:///C:/Documents and Settings/krystan/My Documents/Visual Studio
2008/Projects/HelloWorld/test.build
Target framework: Microsoft .NET Framework 3.5
Target(s) specified: build


build:

     [echo] Hello
     [exec] Microsoft (R) Build Engine Version 3.5.30729.1
     [exec] [Microsoft .NET Framework, Version 2.0.50727.3082]
     [exec] Copyright (C) Microsoft Corporation 2007. All rights reserved.
     [exec]

BUILD SUCCEEDED

Total time: 0.2 seconds.
krystan honour
I'd agree with this - get 3.5 installed and go from there, as even thought your config file is set to use it, if it's not present on the box, you can't access it.
Brett Rigby
A: 

Some times this error is because the build server does not have the sdk installed.

Try installing the windows sdk. You can download it on the Microsoft Download Center

Additional steps may be needed to get nant to recognize the sdk, please refer to this Page Brook's Blog Post

David Lay
A: 

There is a bug in Nant 0.86, see http://sourceforge.net/tracker/index.php?func=detail&amp;aid=1986551&amp;group%5Fid=31650&amp;atid=402868 for more info.

You can download Nant nightly build (currently nant-0.86-nightly-2009-05-05) which has this bug fixed.

pedro