views:

81

answers:

4

Hi all,

Typically when doing a build script for C# I just include */.cs for each project/dll to build. However I now have a situation where I have some .cs files which are not part of the project but live in that directory (they are there for reference purposes from another library). There are not linked in the .csproj file so the VS build works fine but the nant build does not.

Does anyone know if there's a nice easy way of pulling the .cs entries out of the relevant .csproj file and using that as the list of source files to build rather than using a general wildcard match.

Thanks in advance.

+2  A: 

nant has support for automatically building VS solutions, including csproj files, using a <solution> task.

The latest supported solution format is VS 2003.

Matthew Flaschen
"Right now, only Microsoft Visual Studio .NET 2002 and 2003 solutions and projects are supported." Doesn't sound terribly useful these days.
Jon Skeet
+2  A: 

You could build the project using MSBuild via an Exec task instead of invoking compiler directly e.g. msbuild project.csproj.

Lee
+3  A: 

Any particular reason you don't want to use msbuild just for the C# build bit? That's what I do for my Protocol Buffers port, and it works well. It does require nant-contrib, but that's not much of a hardship.

That way you know you only need to get one thing working, and know it'll be built the same way.

You can have a look at my ProtoBuf port build file here, for inspiration. The obvious downside is Mono support, but I believe xBuild is improving...

Jon Skeet
That's exactly how we are doing it. Calling MSBuild via `exec` task like Lee suggested would work as well but with nantcotrib's `msbuild` task it's even more comfortable.
The Chairman
Thanks, msbuild definitely the way to go. My build file is about 1/4 of the size now.
Mike Q
I tried building your ProtoBuf port with xbuild (the .sln), builds fine :)
Ankit
@Ankit: Excellent. I must give that a go some time then. The Mono build script for the port is somewhat primitive at the moment :)
Jon Skeet
+2  A: 

Nantcontrib includes an msbuild task - you can use this to build both projects and solutions. Here's an example of it in practice: http://codebetter.com/blogs/jeffrey.palermo/archive/2006/08/12/148248.aspx

mjd79