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

5

5

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

Retentivity answered 9/3, 2009 at 17:50 Comment(0)
A
9

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>
Adlei answered 9/3, 2009 at 17:54 Comment(5)
Stop answering the same as I'm thinking all the time, before me. At least 10k of your rep should have been mine! :P – Hsu
@configurator: You've been Skeeted! – Solange
Hmm I believe that the link to your own project is broken... πŸ˜‰ – Patricio
@GwynethLlewelyn: Strangely enough, it's quite hard to keep 35,000 answers all up-to-date... (It's been many years since I used NAnt at all.) – Adlei
@JonSkeet: Oh, only 35,000? I thought it was far more than that... 😏 heh! Seriously, thanks for all your answers β€” as well as for all those links. I just happen to be in the middle of hacking & slashing a decade-old project in the hope to resurrect it, ready for the 2020s, and I'm searching for a bit of information on how things used to be, and how old code can be dragged, kicking and screaming, into the new decade. Your own answer was, by far, the most intriguing; it's a pity that the original file you had linked there is gone, though. – Patricio
S
3

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>
Selfconsequence answered 9/3, 2009 at 17:55 Comment(0)
M
2

You can invoke msbuild as a nant task.

Maymaya answered 9/3, 2009 at 17:54 Comment(0)
P
2

solution task might help.

Populace answered 9/3, 2009 at 17:54 Comment(1)
Read under Note: Right now, only Microsoft Visual Studio .NET 2002 and 2003 solutions and projects are supported. – Glynisglynn
S
0

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.

Santalaceous answered 9/3, 2009 at 17:55 Comment(0)

© 2022 - 2024 β€” McMap. All rights reserved.