Monday, February 13, 2006

NUnit MSBuild Task

A very good resource to include NUnit in MSBuild.

Michael F. Collins, III : NUnit MSBuild Task

My easy work around is like this:

Exec Command="nunit-console.exe $(DeploymentPath)\DDTI.Utilities.UnitTest.dll"
WorkingDirectory="$(PROGRAMEPATH)\NUnit-Net-2.0 2.2.6\bin"

I spent quite a few time to work on the MsBuild today. Honestly, I think I gain more understanding on that. One issue which confused me is that when you embed resource file into the assembly. In Vs.2005, it will append the prefix (such as assemblyname.foldername) before the resource name. But in MsBuild, it won't , so it cause some trouble when trying to reference the resource.

One workaround I figured out is to use "Defined Constants" in the CSC command to control the compiling process. It's kind of like this:

#if MSBUILD
set resourcename= "File.xml"
#else
set resourcename= "AssemblyName.FolderName.File.xml"
#endif

Also, always use $ in front of property name and @ in front of item name.

No comments: