Can we use nant to build .sln files in C#?
Can we use nant to build .sln files in C#?
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>
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
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>
solution task might help.
Read under Note: Right now, only Microsoft Visual Studio .NET 2002 and 2003 solutions and projects are supported. β
Glynisglynn
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.
© 2022 - 2024 β McMap. All rights reserved.