Wednesday, March 5, 2008

NAnt and .Net Framework 3.5

When I went to build my first LINQ application on our build server running CruiseControl.NET, the first message I got was:


Solution file error MSB5014: File format version is not recognized. MSBuild can only read solution files between versions 7.0 and 9.0, inclusive


I figured all I needed to do was to force NAnt to use the .NET 3.5 Framework, so I added a line to the NAnt Script as follows:


<property name="nant.settings.currentframework" value="net-3.5"/>



However, then I got the following message

Target framework could not be changed. "net-3.5" is not a valid framework identifier. Valid values are: net-2.0, net-1.1.


So after a little digging on the net, I found that the version of NAnt we were using (0.84) did not yet handle the .NET 3.5 Framework. However there is a Beta version of the 0.86 NAnt tool available, so I downloaded that and installed it to my build server (copied it actually, there is no installer)

The I got the following error

Object reference not set to an instance of an object.


Hmmm. I cleaned up my build server, removing all previous versions of NANT, copied the files from 0.86 back into my NAnt directory, and tried again. Same problem.

Next, I downloaded the latest nightly build from SourceForge and tried my build again


Invalid element . Unknown task or datatype.


WTF!? Where the hell did my msbuild task go? Panic strikes. OMG, I just killed our build server! My boss is gonna kill me!

After a little digging, it turns out that when I cleaned up my server, I'd also removed the latest NAntContrib bin directory, where the msbuild task comes from. So I downloaded the latest NAntContrib package, copied the files to the NAnt directory.

And.... PRESTO! Project building! Well at least it would have been if I hadn't had a path error in my NUnit task. A quick fix, recheck the file into (gah) Visual Source Safe, and a green build light made me feel all warm and fuzzy inside.

All that took me a good chunk of my morning. It would be really nice if SourceForge offered a standard install with the latest NAnt and NAntContrib packaged together for us lazy asses who don't really have 4 hours to blow on getting a build running.

I think that's the number one argument against build servers is how long it takes to set them up. The time they end up saving is tremendous, but you have to be really determined to get it done, and then cross your fingers that you have accurately documented every step in the setup so it doesn't take so freaking long the next time.

My next task... upgrade CruiseControl 1.2.1 to 1.3, though I have heard rumors circulating about CCNET 1.4. Maybe I'll wait till then, and get some real work done.

8 comments:

Sandra said...

I found your blog because I just had the same error as you, about net-3.5 not a valid framework identifier.
Question: have you had any issues with the beta .86 NAnt? We use .85 and I'm a little concerned about using a beta release.

bernie said...

Am having the same problem too..

Solution file error MSB5014: File format version is not recognized. MSBuild can only read solution files between versions 7.0 and 9.0, inclusive


Looks like only version 0.86 supports .net framework 3.5. However NAntcontrib is at version 0.85 and looking at the documentation there is no mention of .net framework 3.5. Does Nant 0.86 Beta and NAnt contrib 0.85 work ok togthter

Sandra said...

bernie... after some testing, we are now using NAnt .86 Beta and the NAnt contrib .85 together, as we had a need for some targets within the contrib .dlls. So far, all is working fine.

Hope that helps.

JB said...

We haven't had any problems, except that we haven't been able to upgrade out server to CCNET 1.3. CCNET wouldn't start. That was months ago, and I haven't spent a lot of time updating the build scripts since they ain't broke, I'm not going to fix them

I did get SandCastle working with the builds in our current environment, and that was a royal pain too.

I never knew how many hours I spent implementing time saving tools until I had to track the time really accurately. I know these tools save time in the long run, but they sure have a big upfront cost.

I've considered converting to MS Team Builder, but I sure can't justify the effort and cost at this point.

EmrysX said...

Thanks so much for this. Ran into this exact problem when updating to 0.86-beta1 today.

Cheers!

Anonymous said...

lelijke os!

Charles said...

Ran into this problem.

Thanks for posting!

Antebios said...

I recently ran into the same problem. I sort of knew what to do, but you just confirmed what I think should work. I upgraded to the latest Framework 4.0, nant 0.91, and ncontrib. It all worked without needing Visual Studio installed!!