Motivation
It's quite easy to install Castle by using the MSI file provided on the download page. But that one is RC2 and now nearly half a year old. Newer features and projects, such as the Validator component, are currenly only available in the trunk. Another benefit is that if you encounter a nasty error in the Castle Project, chances are good that it is already fixed or will be fixed. But that fix will live only in the trunk.
The download page says that you're best off with installing the MSI if you need VisualStudio integration. This article helps you integrating the trunk so that you have both VS integration and the newest Castle version available.
Tools of the Trade
- VisualStudio. I wrote this article using VS2005Pro SP1 english. Other versions and languages may work as well
- An SVN client. I prefer TortoiseSVN
, but the command line binaries
are fine too. Although I like AnkhSVN
for versioning my own projects, it is not much help in this case, as it doesn't allow to check out folders, only solutions.
- NAnt 0.85
for building Castle
- nUnit 2.2
if you intend to run the unit tests before building. I left that out in this guide.
How to install
Installing Prerequisites
If you are using VS2005 without Service Pack, you have to install the web projects support
to create MonoRail projects. SP1 already includes that add-on.
Of course the applications listed above should be installed too. NAnt also needs to be placed on the PATH.
Getting the Sources
Configure your SVN client (mind the proxies) and check out the complete castle repository into a local directory. I don't check out only the trunk, but the whole repository at https://svn.castleproject.org:/svn/castle
. You'll only need to check it out once, so the size of the download won't matter much in the long run. For this guide, I assume the code is checked out into c:\data\castle\castle (the second castle is because I also checked out CastleContrib, which is not needed here, but very useful otherwise).
Building Castle
This section requires you to change the Global Assembly Cache (GAC) which requires Administrator privileges.
Build the Castle project using the commandline. Navigate to the trunk folder (c:\data\castle\castle\trunk) and call NAnt:
nant -t:net-2.0 -D:common.testrunner.enabled=false
 | Unit Tests
The code above omits the unit tests from building castle, because it's tricky to create the environment for the tests to succeed. This is especially true for MonoRail tests.
So, I assume that all tests succeed when the code was commited and now I can omit them  |
 | Possible Reasons the build might fail
Sometimes when doing a build I get a message stating that Failure adding assembly to the cache: Access denied which happens because VS2005 is open and one of the projects references Castle.MonoRail.TestSupport.dll |
Building the Wizards
Now it's possible to use the trunk. However, the wizards in VS.NET are still from RC2 and they will reference the RC2 libraries in the generated project.
Updating the wizards is easy with NAnt:
nant -t:net-2.0 -D:dev.env.dir="%DevEnvDir%" -D:build.warnaserrors=false
On my machine, NAnt wasn't able to read the environment variable, so I added it as a parameter. Due to an unsatisfied requirement, there will be a warning during compilation. To avoid NAnt bailing out due to this, you have to set the property build.warnaserrors.
Now, the file Castle.VSNetIntegration.CastleWizards.dll should exist in your build directory.
Registering the Wizards
If you are compiling with NAnt only, the Wizards will not be registered. You must do this manually by navigating to your build output directory and calling
regasm.exe Castle.VSNetIntegration.CastleWizards.dll
Changing the Registry
Now the new wizards are created and registered, but they still use the RC2 libraries. This must be changed by updating the paths to the new directories in the registry. I have created a reg-file for that. Copy the contents to a file, customize the path and then double click it.
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Castle]
"vs8templatelocation"="C:\\data\\Castle\\Castle\\trunk\\Tools\\VSNetWizards\\CastleTemplates\\VS8"
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\v2.0.50727\AssemblyFoldersEx\castle]
@="C:\\data\\Castle\\Castle\\trunk\\build\\net-2.0\\debug"
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\CLSID\{1D90721C-B0AA-4F9A-BDE5-A588911E38B6}\InprocServer32]
"CodeBase"="file:
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\CLSID\{1D90721C-B0AA-4F9A-BDE5-A588911E38B6}\InprocServer32\1.0.6.10]
"CodeBase"="file:
[HKEY_CLASSES_ROOT\CLSID\{9FF77D9F-E4FC-47EE-8E8B-0079FC2F2478}\InprocServer32]
"CodeBase"="file:
[HKEY_CLASSES_ROOT\CLSID\{9FF77D9F-E4FC-47EE-8E8B-0079FC2F2478}\InprocServer32\1.0.6.10]
"CodeBase"="file:
Updating Castle
The only thing left is regularly updating the SVN working copy and rebuild the binaries to keep pace with the project.
How about additional instruction for castle Linux + Mono?