BitterCoder's Wiki

Edit

Overview



Warning: These instructions are out of date - the build process for RhinoTools has been migrated to NAnt, and is missing many of the options outlined near the end of this document. Search the RhinoTools google group for help on building RhinoTools.

This wiki topic outlines the process for building the Castle/NHibernate/RhinoTools stack (which I will call the Castle Stack(ish) TM from here on in) and in particular taking advantage of the build scripts Ayende & fellow Contributors have written as part of Rhino-tools project.



Edit

Getting Started

Before you begin, install the latest version of Nant, and make sure it's available in your environment path, and also install both svn (for the command line tool svn).

Edit

Checking Everything Out

Then create a folder where all the projects will be placed, i.e. C:\dev\Shared\

In this folder create a new folder for each of the repositories, and check each of them out from the associated url using tortoise svn (or the command line tools, if your that way inclined).


Edit

Building Everything for the first time

At this point you can now build the projects, the suggested build script/order for this comes from Ayende's post on the subject:

Ayende's directions look like this:

C:\dev\Shared>cd NHibernate
C:\dev\Shared\Nhibernate>svn up
C:\dev\Shared\Nhibernate>cd nhibernate
C:\dev\Shared\NHibernate\nhibernate>nant
C:\dev\Shared\NHibernate>cd ..\..
C:\dev\Shared>cd Castle
C:\dev\Shared\Castle>svn up
C:\dev\Shared\Castle>nant
C:\dev\Shared\Castle>copy ..\NHibernate\nhibernate\build\NHibernate-2.0.0.Alpha1-debug\bin\net-2.0\*.* build\net-2.0\debug /y
C:\dev\Shared\Castle>nant
C:\dev\Shared\Castle>copy ..\NHibernate\nhibernate\build\NHibernate-2.0.0.Alpha1-debug\bin\net-2.0\*.* ..\RhinoTools\SharedLibs\NHibernate /y
C:\dev\Shared\Castle>copy build\net-2.0\debug\*.* ..\RhinoTools\SharedLibs\Castle\*.* /y
C:\dev\Shared\Castle>cd..
C:\dev\Shared>cd RhinoTools
C:\dev\Shared\RhinoTools>msbuild BuildAll.build


The second time Castle is built it's likely you will strike some errors because you haven't patched it for the NHibernate trunk.

Edit

Castle Build Failures

Now if during the above process the castle build fails with compiler (CSC) errors, they will need to be fixed before you can proceed with the rest of the directions.

Likely places in the Castle trunk for compilation failures are:

  • ActiveRecord - the HookDispatcher.
  • ActiveRecordIntegration - ISession & ISessionFactory not entirely implemented.
  • NHibernateIntegration - ISession not entirely implemented & the TestIntercepter in the NHibernateIntegration test suite.

Normally fixing these is an iterative process i.e. fix, rebuild, fix next problem etc. until you get a successful build against the NHibernate trunk. Fixing them is trivial i.e. for the ISession & ISessionFactory it's normally just a matter of implementing the missing interface members on the decorator, and flowing the call to the inner instance, for the HookDispatcher it's a matter of changing a return type from object to bool?.

Once your able to build castle without any compilation failures - and you have built NHibernate / RhinoTools manually you can proceed to automate the process using Ayende's build files - you could probably skip this step, but I find it's generally worth getting it to work manually to verify the process before proceeding with RhinoTools build files.

Edit

RhinoTools build failure

Depending on the current state of the RhinoTools you may find some of the projects don't build, a likely candidate is the Rhino-ETL project, in which case it may be worth copying the BuildAll.build file to a new file (say BuildMost.build) and removing the rhino-etl\default.build; from the list of MsBuild projects which are being built.

That projects that you need to ensure do build without errors are:

  • RhinoMocks
  • Rhino Commons
  • Rhino Nhibernate Query Generator (NHGQ)

Any projects in RhinoTools which fail (other then these) can probably be ignored if they are failing, at least for the BuildFromTrunk.build file to work.

Once you get a successful build of these projects you can then move on to automating the trunk update process using BuildFromTrunk.build.

Edit

Using BuildFromTrunk.build in RhinoTools

Have a quick read through the "How to build.txt" file in root of the RhinoTools project (just in case things have changed since I wrote this wiki entry) - and then copy/paste the "BuildFromTrunk-Config.build.sample" file to "BuildFromTrunk-Config.build" and edit it to match your paths and preferences, in my case this is:

<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Update-All;Build-All;Copy-To-Artifact-Dir" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
	
	<PropertyGroup>
		<Configuration>debug</Configuration>
		<Enable-Tests>false</Enable-Tests>

<Dest-Dir></Dest-Dir> <Dest-Lib-Dir>$(Dest-Dir)\libs\$(Configuration)</Dest-Lib-Dir> <Dest-Tool-Dir>$(Dest-Dir)\tools</Dest-Tool-Dir>

<Tools-Dir>$(MSBuildProjectDirectory)\SharedLibs\Tools</Tools-Dir> <NH-Dir>$(MSBuildProjectDirectory)\..\NHibernate\nhibernate</NH-Dir> <Castle-Dir>$(MSBuildProjectDirectory)\..\Castle</Castle-Dir> <Rhino-Dir>$(MSBuildProjectDirectory)</Rhino-Dir> <Artifact-Dir>$(MSBuildProjectDirectory)\Trunk-Artifacts</Artifact-Dir>

<MSBuildCommunityTasksPath>$(Tools-Dir)</MSBuildCommunityTasksPath> <Svn-Dir>$(Tools-Dir)\Subversion</Svn-Dir> </PropertyGroup> </Project>


You can then run the command msbuild BuildFromTrunk.build /t:Build-All and after 3 or 4 minutes it should complete, with the Castle, NHibernate and RhinoTools projects all rebuilt, great... but this script does more then that.

If you now run msbuild BuildFromTrunk.build without specifying a target, it will use the default targets of:

Update-All;
Build-All;
Copy-To-Artifact-Dir


Which will perform svn up on all the projects, build them, and copy the output artifacts to the artifact directory specified in the BuildFromTrunk-Config.build file.

This may fail with a message like this:

svn: PROPFIND request failed on '/svnroot/rhino-tools/trunk'
svn: PROPFIND of '/svnroot/rhino-tools/trunk': Server certificate verification failed: issuer is not trusted (https://rhino-tools.svn.sourceforge.net)


If you have not run an svn up on the RhinoTools or NHibernate project manually and accepted their untrusted SSL certificates (p)ermanently.

At this point you now have a RhinoTools\Trunk-Artifacts\debug\ folder containing all the debug dll's for Castle, NHibernate, RhinoCommons, RhinoMocks etc. - as fresh as you can get it!

Welcome to the trunk club.

Edit

Setting up "MyBuild"

For some this may be enough, but this can be taken one step further yet, by automatically pushing the appropriate set of assemblies to your various projects that are built on the Castle(ish) TM stack.

In RhinoTools there is a file called "MyBuild.build.sample" copy and paste it to a file called "MyBuild.build" and then open it in your favorite text editor.

The file looks like this:

<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="DoAll" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
	
	<Target Name="Copy-Projects">
		<CallTarget Targets="Copy-ProjectX" />
	</Target>

<Target Name="Copy-ProjectX"> <MSBuild Projects="BuildFromTrunk.build" Targets="CopyTo" Properties="Configuration=release ;Dest-Dir=C:\export\code\ProjectX\trunk ;With-NH=true;With-Nhqg=true;With-Rhino-Commons=true;With-SqlLite=true" /> <MSBuild Projects="BuildFromTrunk.build" Targets="CopyTo" Properties="Configuration=debug ;Dest-Dir=C:\export\code\ProjectX\trunk ;With-NH=true;With-Nhqg=true;With-Rhino-Commons=true;With-SqlLite=true" /> </Target>

<Target Name="DoAll"> <CallTarget Targets="Rebuild-Trunks" /> <CallTarget Targets="Copy-Projects" /> </Target>

<Target Name="Rebuild-Trunks"> <CallTarget Targets="Update-Trunks" /> <CallTarget Targets="Build-Trunks" /> <CallTarget Targets="Copy-Trunks" /> </Target> <Target Name="Update-Trunks"> <MSBuild Projects="BuildFromTrunk.build" Targets="Update-All" /> </Target>

<Target Name="Build-Trunks"> <MSBuild Projects="BuildFromTrunk.build" Targets="Build-All" Properties="Configuration=debug" /> <MSBuild Projects="BuildFromTrunk.build" Targets="Build-All" Properties="Configuration=release" /> </Target>

<Target Name="Copy-Trunks"> <MSBuild Projects="BuildFromTrunk.build" Targets="Copy-To-Artifact-Dir" Properties="Configuration=debug" /> <MSBuild Projects="BuildFromTrunk.build" Targets="Copy-To-Artifact-Dir" Properties="Configuration=release" /> </Target> </Project>


Basically the process is for each project you add a target, like the sample "Copy-ProjectX" target, and then add the project in as a step in the Copy-Projects target.

Notice there are two configurations, one for debug and one for release... let's have a look at what makes up the debug target for ProjectX:

<MSBuild Projects="BuildFromTrunk.build" Targets="CopyTo"
Properties="Configuration=debug
;Dest-Dir=C:\export\code\ProjectX\trunk
;With-NH=true
;With-Nhqg=true
;With-Rhino-Commons=true
;With-SqlLite=true" />


So we can see it is:

  • Setting a destination directory (the libs or tools path is appended based on how you've setup your BuildFromTrunk-Config.build file).
  • Including features by passing With-XXX=true name/value pairs - this determines which assemblies are copied to your project (in this case, nhiberate, rhino commons and sql lite and the nhibernate query generator tool).

And yes, It is smart enough to determine all the underlying dependencies for a feature as well, so you don't need to manage that knowledge yourself (or go mad specifying every single dependency your project has).

The set of supported values for the With-XXX syntax are as follows:

OptionCategoryDescription
With-NHNHibernateNHibernate
With-NH-SearchNHibernate
With-NH-MappingNHibernate
With-NH-PrevalenceNHibernate
With-NH-MemCachedNHibernate
With-NH-SysCacheNHibernate
With-NH-SysCache2NHibernate
With-NH-SqlTypesNHibernate
With-NH-OraTypesNHibernate
With-NH-IntegrationNHibernateCastle NHibernate Integration facility.
With-MicroKernelCastle
With-WindsorCastle
With-LoggingCastleLogging facility
With-Log4NetCastleLog4Net logging service
With-ARActiveRecordActive Record
With-AR-IntegrationActiveRecordActiveRecord Integration facility
With-TransactionActiveRecordTransaction support
With-AtmActiveRecordAutomatic transaction
With-BinderCastleMisc
With-ValidatorCastleMisc
With-TemplateEngineCastleMisc
With-NVelocity-TemplateEngineCastleMisc
With-EmailCastleMisc
With-DictionaryAdapterCastleMisc
With-MRMonorailMonorail
With-MR-AR-SupportMonorailActiveRecord support for Monorail
With-MR-AR-ScaffoldingMonorailScaffolding support for Monorail
With-MR-WindsorMonorailWindsor integration for Monorail
With-MR-NVelocityMonorailNVelocity view engine for Monorail
With-MR-BrailMonorailBrail view engine for Monorail
With-MR-JsonMonorailJSON support for Monorail
With-MR-AspViewMonorailAspView view engine for Monorail (from CastleContrib)
With-MR-ViewComponentsMonorailViewComponents for Monorail (from CastleContrib)
With-Cstl-CodeGenMonorailCastle.Tools.CodeGenerator for Monorail (from CastleContrib)
With-Rhino-CommonsRhinoToolsRhino Commons library
With-Rhino-Commons-NHRhinoToolsRhino Commons NHibernate library (required for IRepository now)
With-Rhino-Commons-ARRhinoToolsRhino Commons ActiveRecord library (dep. on With-Rhino-Commons-NH)
With-Rhino-MocksRhinoToolsRhinoMocks mocking framework
With-NhqgRhinoToolsNHibernate Query Generator Tool.
With-Rhino-TestingRhinoToolsRhino Testing
With-SqlLiteRhinoToolsSql Lite libraries (useful for testing)
With-SqlCeRhinoToolsSql Ce Libraries (useful for testing).

You can now build with the following command line msbuild MyBuild.build and it will update, compile, populate the trunk artifacts and then copy the required debug and release artifacts to the libs directory of your project.

Though a little laborious to get setup initially, getting this process working will save you a lot of time in the future - hope you find this useful.

Edit

ActiveRecord/NHibernate gotchas

In moving to the trunk you may find your existing ActiveRecord code wont work and throws an exception with one/all of these messages:

  • Error adding information from class XXXXXXXXX to NHibernate.information"
  • Could not compile the mapping document: (string)
  • The dialect was not set. Set the property 'dialect'.

This is because the "hibernate." prefix is no longer required on the various configuration properties.

So change something like this in your app config for ActiveRecord:

<activerecord isWeb="true" pluralizeTableNames="true">
	<config>
		<add key="hibernate.connection.driver_class" value="NHibernate.Driver.SqlClientDriver" />
		<add key="hibernate.dialect" value="NHibernate.Dialect.MsSql2000Dialect" />
		<add key="hibernate.connection.provider" value="NHibernate.Connection.DriverConnectionProvider" />
		<add key="hibernate.connection.connection_string_name" value="Default" />
		<add key="hibernate.show_sql" value="true" />
	</config>
</activerecord>


to this:

<activerecord isWeb="true" pluralizeTableNames="true">
	<config>
		<add key="connection.driver_class" value="NHibernate.Driver.SqlClientDriver" />
		<add key="dialect" value="NHibernate.Dialect.MsSql2000Dialect" />
		<add key="connection.provider" value="NHibernate.Connection.DriverConnectionProvider" />
		<add key="connection.connection_string_name" value="Default" />
		<add key="show_sql" value="true" />
	</config>
</activerecord>


Edit

TO DO

These directions provide a reasonable starting point for getting your project working from the trunk... however to be truly productive a few things from the Castle contrib project need to be added to your project as well (in particular the Monorail View Components, which I find very useful).

In the future I will hopefully add some directions on how to build and include the Castle contrib projects with the trunk.

Edit

Support

There are a number of places to get support for building from the trunk including:


I don't suggest trying the NHibernate groups, as seldom is a problem related to building NHibernate (and you get access to a number of NHibernate developers on those others lists at any rate which are used to working from the Trunks).

Alternatively flick me a comment on my blog and I can have a go at helping you out.

ScrewTurn Wiki version 2.0.2. Some of the icons created by FamFamFam.