Tuesday, September 21, 2010

NAnt and the .Net 4 error

NAnt threw this odd error today.

The reason for it being odd was the version of the .Net framework being used in the call: .Net 4.0, instead of 3.5.  While I have 4.0 installed, I was trying to build a 3.5 project.

A little searching and I soon had a good guide of how to build 4.0 projects using NAnt, but this wasn't the solution to my problem.

Why 4.0?

Now it is possible to tell NAnt which framework to use, the -t: switch from the command line or in the main NAnt.exe.config file. I tried, and failed. NAnt threw the same error.

I wanted to stop NAnt using .Net 4.0, but how? Well, near the bottom of the config file is a list of supported Frameworks, of which 4.0 is one.

Removing the entry for 4.0 fixed the problem. Certainly this is a quick fix as NAnt has a problem with .Net 4.0 on my PC, but not a problem to be fixed today.


Thanks to Rawdon for mentioning the path to the configuration file. You can find this in %InstallLocation%\NAnt\bin\NAnt.exe.config

Also from the comments. Paul Stewart has found the cause of the problem and written it up in this post.

Monday, September 13, 2010

TFS and MSBuild properties

My current client uses TFS as build server and MSBuild for deployment scripts. Whenever I have to change the scripts I spend time searching for the various properties which they expose. So this is my reminder, to kick start the process next time.


There are many different ways of using MSBuild but the list of Reserved Properties is always a good start. An example property is “$MSBuildProjectFile”, which returns the directory where the project file is located. From here I can often navigate using relative paths to the various places I need to go.

Any talk of MSBuild would not be complete without mentioning these extension libraries; SDC Tasks and MSBuildTasks. They provide a hosts of extras from re-writing XML files to creating web sites.


The build process (Team Build) is built upon MSBuild and, like all processes which are managed with MSBuild, it provides a set of extensions for querying the environment and managing the process. The first port of call is the MSDN page. After reading through this which is lengthy, I would recommend having a look at Martin Woodward’s post; useful Team Build properties.