tags:

views:

1327

answers:

5

Can we use nant to build .sln files in C#?

+1  A: 

You can invoke msbuild as a nant task.

Mehrdad Afshari
+2  A: 

solution task might help.

Canavar
Read under Note: Right now, only Microsoft Visual Studio .NET 2002 and 2003 solutions and projects are supported.
Petar Repac
+6  A: 

The easiest approach in my experience is to use NAnt to call MSBuild, and get MSBuild to build the solution file itself. See my Protocol Buffers build file as an example.

I use NAntContrib which has an msbuild task:

<property name="nantcontrib-dir"
   value="${path::combine(nant::get-base-directory(), '../../NAntContrib')}"
   overwrite="false" />

<loadtasks assembly=
    "${path::combine(nantcontrib-dir, 'bin/NAnt.Contrib.Tasks.dll')}" 
 />  

...

<target name="build"
        description="Builds all C# code">
  <msbuild project="${src}/ProtocolBuffers.sln">
    <property name="Configuration"
              value="${build-configuration}" />
  </msbuild>
</target>
Jon Skeet
Stop answering the same as I'm thinking all the time, before me. At least 10k of your rep should have been mine! :P
configurator
@configurator: You've been Skeeted!
Michael Myers
+1  A: 

msbuild task that can either just build your solution or execute an entire msbuild script:

<target name="compile">
       <msbuild project="xxx.sln">
              <arg value="/property:Configuration=release" />                                  
              <arg value="/t:Rebuild" />
       </msbuild>
</target>
Darin Dimitrov
A: 

You can use the solution task although that's not been supporting VS2008 solutions outside of the Beta versions of nant. It's coming though.

Ian Suttle