NAnt for automating builds in C# works fine....
I've been learning NAnt the past few days, and it's really quite simple. Unfortunately, using it with NUnit isn't. I'm supposed to be able to use NAnt to build my projects automatically and test them too, all with one quick call to a batch file:
./build.bat test
where build.bat just calls nant.exe and passes it a buildfile, which is an xml file that includes "targets" for nant to run. NAnt compiles my project and my test project just fine, but then when NUnit runs, I get some messed up errors. I can run my tests properly in Visual Studio using ReSharper, and they behave properly, but it doesnt work on the command line using NAnt...what the crap is up?!
A couple notes for you:
my folder structure is as follows :
src : contains application projects in one folder (app) and test projects in another (test)
build : should be deleted and rebuilt every time NAnt runs
config : contains config files for the project
tools : contains the NAnt folder and the NUnit folder including the exe's and dll's
lib : 3rd party libraries
base : contains the above folders, as well as the .sln, the batch file and the buildfile for NAnt.
There were a few solutions that seemed to work for various scenarios, but I think the one that will work most consistently (and unfortunately is a bit cumbersome) is this:
Use NAnt to clean and rebuild your projects and tests into a single folder (/tmp). Then, place all the NUnit dll's directly into that same folder. Any references to NUnit should point to the copy in the tools folder. Then, when everything is built and the NUnit dll's are placed in the tmp folder, run the tests from the base directory through NAnt by creating a new "target" in the buildfile that runs nunit-console.exe. The target should have no dependencies. You may also need to add this to the nunit-console.exe.config file:
underneath the configuration opening tag put:
<startup><supportedruntime version="v4.0.30319"/>
and under the runtime opening tag put:
<loadfromremotesources enabled="true" />
I'll have to do this everytime I build, until I figure it out...lame.
P.S. I learned to use NAnt from my bro, and from here:
http://blog.developwithpassion.com/2006/04/automating-your-builds-with-nant-part-1
Thank you for sharing your insights! Much like this post of you :)
ReplyDeleteCheck out our site for more:
ecommerce templates