Blog Stats
  • Posts - 90
  • Articles - 0
  • Comments - 39
  • Trackbacks - 2

 

Using NAnt to build .NET 3.5 solutions

First, let me recommend Mike Robert's excellent article on setting up .NET solutions.

My preference is to use MSBuild to build the Visual Studio solutions, and NAnt for everything else. The trouble is, in the latest version of NAnt (0.86-beta1) the <solution> task does not support .NET 3.5.  The best work around I can find is to use the <exec> task to call MSBuild to build the solution. Here is a basic Nant build script that does this:

<?xml version="1.0" ?> 

<
project name="nant" default="compile" xmlns="http://nant.sf.net/schemas/nant.xsd">

<
property name="nant.settings.currentframework" value="net-3.5" />
<property name="project.rootdirectory" value="." />
<property name="solution.dir" value="src"/>
<
property name="solution.file" value="${solution.dir}/Mysolutionfile.sln"/>
<
property name="build.configuration" value="debug" />

<target name="compile">
<exec program="${framework::get-framework-directory(framework::get-target-framework())}\msbuild.exe"
commandline="${solution.file} /t:Clean /p:Configuration=${build.configuration} /v:q" workingdir="." />
</target>

</project>

Feedback

# re: Using NAnt to build .NET 3.5 solutions

Gravatar Come to the dark side and start doing all your build scripts in MSBuild =). 5/1/2008 10:58 AM | Chris Eargle

# re: Using NAnt to build .NET 3.5 solutions

Gravatar I am using nant to build 3.5 solutions. You just have to add 3.5 to the list of supported frameworks, there are several tutorials in the wild.
In general I am like you, I prefer using msbuild for the solution, so I use NantContrib to do so.
NantContrib, provides a more declarative mechanism for firing msbuild from nant as well. 6/26/2008 8:11 AM | Chris Chandler

# re: Using NAnt to build .NET 3.5 solutions

Gravatar I'm looking to migrate my build system from msbuild to nant, so this will be helpful. Quick tip, though- Using the "pre" tag lets text shoot out the side. On my browser (ff3, also tried ie7) it shoots straight out of the column into the blue background area, making the blue text near invisible. With this thin vertical layout, you might fare better with a "code" tag instead of "pre" 7/16/2008 1:09 PM | Alex

# re: Using NAnt to build .NET 3.5 solutions

Gravatar Hey thanks for the example. I have seen a half dozen others and this is the first one that worked on my machine all the rest use the solution tag which doesn't work with Visual Studio 2008.

Now that I can build it as described above. How do I publish the built projects(s) to a file. I have 7 projects three of which are web applications which need to be published to some folder say "/Publish/MyProject/" how do I do that. 11/7/2008 10:20 AM | bret

# re: Using NAnt to build .NET 3.5 solutions

Gravatar Thanks downloaded the newsletter and forwarded it to my friends.Thanks for a resourceful content. this is what i have been looking for so long. 8/1/2009 8:44 AM | tiffany

# re: Using NAnt to build .NET 3.5 solutions

Gravatar Hi, i have a solution with about 5 project inside of the solution, when trying to build I get the following error : MSB1008 : Only one project can be specified...

How can you build multiple projects in one solution? 8/7/2009 5:19 AM | Morne

# re: Using NAnt to build .NET 3.5 solutions

Gravatar The example in this project builds a solution with many projects. 8/7/2009 7:25 PM | Liam McLennan

# re: Using NAnt to build .NET 3.5 solutions

Gravatar I use it as you describe it here and it works great.
Thank you! 10/24/2009 1:37 PM | 24 inch bar stools

Post a comment





 

 

 

Copyright © Liam McLennan