Building NHibernate 1.2.1GA on .NET 3.5

Published 20 March 08 02:49 PM

I recently reached a point where for reasons that I'm sure you can all relate to, I decided to clean my laptop and rebuild.  I therefore did a clean install of Vista with SP1.  As a quick aside, SP1 does actually seem to improve performance - particularly when starting up or closing down.  Anyway, after I was back up and going again, I setup NAnt and then downloaded the NHibernate 1.2.1 GA source.  However, I ran into 2 major problems building, so I thought I would share those, along with how to work around them.

Both problems can be corrected by modifying the markup in the build-common/common.xml file.

The first problem had to do with the fact that the build was expecting the clover library.  The solution was simply to add a condition to the property set declaration.  I'm not going to spend any more time on this one, because the problem/solution is documented here.

The second problem is that there is no target in the build file for .NET 3.5.  On most machines, this isn't a big deal because you've probably upgraded framework versions incrementally, and the build file can target 2.0 with no problem.  Because I have a fresh OS/Framework install, I got an error saying that .NET 3.5 is not supported for my build of NHibernate.  This can be worked around by adding a target declaring a configuration for .NET 3.5, like so:

<target name="set-net-3.5-framework-configuration">
    <property name="nant.settings.currentframework" value="net-2.0" />
    <property name="current.build.defines" value="${build.defines}NET,NET_2_0" />
    <!-- not using SDK_v2_0 because ndoc throws an exception -->
    <property name="link.sdkdoc.version" value="SDK_v1_1" />
    <property name="merge.targetplatform" value="v2.0" />
</target>

When you get into the config file, you'll see that all I did was create a target with 3.5 declared as a part of the target name, and then coped the body from the 2.0 target inside of my 3.5 target.  Initially, I had actually configured the properties to make them specific to .NET 3.5.  Unfortunately, I later discovered when I tried to use the compiled assemblies that many of the source files have preprocessing directives that are specific to the defines declared in the build properties.  For example, the ISet<T> source code is wrapped with the following directive.

#if NET_2_0

Anways, after making these 2 changes, I was able to build with no problem, and NHibernate continued to work as advertised.

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

# MSDN Blog Postings » Building NHibernate 1.2.1GA on .NET 3.5 said on March 20, 2008 6:44 PM:

PingBack from http://msdnrss.thecoderblogs.com/2008/03/20/building-nhibernate-121ga-on-net-35/

# Shawn Hempel said on May 20, 2008 5:35 PM:

I'd argue that using a directive like "NET_2_0" was short-sighted on the part of NHibernates developers.

Something more specific to the problem being addressed would have made more sense and prevented your 3.5 properties issue, such as:

#if GENERICS

Quite possible that they could be convinced to change it going forward. Certainly they'll have to if they intend to build on NET_3_5 or NET_4_0, etc.

# Luca Molteni said on August 26, 2008 6:16 AM:

Actually, your target section gave me an ant problem with the framework 2.0, I removed the first line, and it all worked currectly.

<target name="set-net-3.5-framework-configuration">

       <property name="current.build.defines" value="${build.defines}NET,NET_2_0" />

   <!-- not using SDK_v2_0 because ndoc throws an exception -->

   <property name="link.sdkdoc.version" value="SDK_v1_1" />

   <property name="merge.targetplatform" value="v2" />

</target>

Bye, and thanks for your help.

Leave a Comment

(required) 
(optional)
(required) 

  
Enter Code Here: Required

About hdierking

I am currently the Editor-in-Chief for MSDN Magazine. I joined Microsoft in 2006 as a product planner with the certification team at Microsoft Learning. Prior to that, I spent my career as a developer and later as an architect. My main technology passions include pretty much anything on language theory, agile development, and service-oriented architecture.
Page view tracker