Building Dot Net
Some notes on building and testing .NET programs; more specifically CSharp.
Building
Use NAnt, it works, it's free, it understands Microsoft's compiler (csc) and Mono. It can execute NUnit and loads of other stuff.
Testing
Write the tests first. If you can't make yourelf do that at least write them in parallel. Use NUnit to execute the tests then it will be easy to run them from NAnt. Of course NAnt can execute your code anyway so you can build your own adhoc tests. Doing it with NUnit is better because you will be able to run from NAnt, from the command line or from the NUnit GUI and because NUnit provides a straightforward way to annotate tests to turn them on and off.
How to get NAnt and NUnit to work together
When I started using NAnt and NUnit together everything went swimmingly until I wanted to read som XML files with XmlTextReader. Nunit failed with error messages complaining about permissions and strong names. I eventually found a mail archive that told me what I had to do.
The trick is simply to edit the config files of all of the involved
programs to make sure that they have a startup
element that contains
a supportedRuntime
element that specifies the correct runtime before
any other runtime.
I had to modify nunit-gui.exe.config, nunit-console.exe.config,
NAnt.exe.config. Neither nunit-gui.exe.config nor
nunit-console.exe.config had a startup
element so I added:
<startup> <supportedRuntime version="v1.1.4322" /> </startup>
This goes in the configuration
element.
For Nant it was slightly different because it already had a startup
element which looked like this:
<startup>
<supportedRuntime version="v1.0.3705" />
<supportedRuntime version="v1.1.4322" />
</startup>
The fix was simple, just reverse the order of the tow
supportedRuntime
lines:
<startup>
<supportedRuntime version="v1.1.4322" />
<supportedRuntime version="v1.0.3705" />
</startup>
No comments:
Post a Comment