views:

1262

answers:

3

I am working on a big C++ project. It is building using single Ant script which makes possible to compile the same source targeting more than one platform and compiler.

But, I have to work only for Windows platform and Visual Studio 2005 C++ compiler. It would be really nice if I could write code and compile in Visual Studio, instead of using Notepad++ and Ant scripts, as I do now.

I tried to install Nant and Nant addin for Visual Studio 2005, and to use existing Ant script, but it seems that Ant script cannot be used as a Nant script.

Is there any way to convert Ant script to Nant? Is any other approach to the problem at all, or I must create Visual Studio solution and projects manually?

I would try to avoid such solution because I have a bunch of tests that I don't know how to use in that case.

+1  A: 

To my knowledge, there is no automatic way of converting Ant script to NAnt. However, since NAnt is based off of the Ant the conversion process would not be too far from the original, as long as the tasks are the "core" ones. Possibly an XSLT translation could be made on the Ant scripts to convert to NAnt as both are XML. If one were to go down this path the conversion should be done dynamically based of the original Ant scripts, so that only one set of scripts would have to be maintained.

If you would like to write and compile your C++ code inside of Visual Studio it's tough to beat the functionality that is built in with the IDE. However, this requires creating project files though. Otherwise, it seems that one would risk fighting an uphill battle with the tool.

One option for the tests would be to call out through a custom build step to run them.

Scott Saad
+1  A: 

In my experience, the best way to integrate VS with ant is on the IDE side to call ant as a custom build step (as Scott Saad suggests), and from ant, to call msbuild.exe as the executable to build the project from the command line.

I know that this question is already answered -- I just wanted to suggest the possibility of using msbuild, as it's by far the easiest way to build VS projects from within ant itself.

Nik Reiman
msbuild/vcbuild rocks pretty much in this case, yeah.
Marcus Lindblom
A: 

Use MSBuild tasks wrapped within an NAnt task. I had to do this at my last job and it was the best solution I could come up with, then again I could just be very bad.

Woot4Moo