|
nServiceBus is an open source, distributed communications framework. Find out how to get the code, compile it, and get pointers like getting the latest successful build.
nServiceBus has been in development since 2007 and is presently at version 1.9 with a new version expected to be available soon.
nServiceBus version 1.9 focused on configuration - specifically, making configuring and deploying nServiceBus much simpler as compared to previous versions. The last article, Up and Running with nSerivceBus, described how get one of the nServiceBus samples running with minimal effort by downloading a ZIP file.
The ZIP file you download contains a snapshot of the solution as it was when the ZIP got created. You end up with a set of runnable samples, but the underlying code is slightly out of date. You can get more up to date code by getting a newer version.
Currently there three versions of nServiceBus:
- Version 1.9, as published in a ZIP file
- Version 1.9 - under source control as a branch: includes latest corrections and enhancements since the release of version 1.9
- Next version - under source control on the trunk (main branch) - includes corrections and enhancements that are likely to make it to the next released version
The version you choose depends on your intentions: the ZIP file from April 2009 is prefect if you just want to experiment with nServiceBus using the samples. Version 1.9 from the branch under source code control addresses a number of important issues for using nServiceBus in productive environments. The next version - the code on the trunk (main branch) is great for planning purposes, and possibly productive use if you don't mind working on the leading edge.
The next version also offers an extra benefit: continuous integration. Continuous Integration, or CI, is a practice that ensures that code that is committed to the repository successfully compiles without depending on files that are not in the repository. CI offers the assurance of working with code that compiles, thereby helping to reduce your effort when committing changes to the trunk.
nServiceBus achieves CI through automated builds that run on TeamCity, a distributed build management and continuous integration server. The screenshot that follows shows the last series of successful builds:

You can also get a copy of the code that TeamCity built by downloading a ZIP file that gets created at the end of each build.
The rest of this article walks you through the process of getting code from the trunk (main branch). If you just want to experiment with nServiceBus, refer to my previous article, "Up and Running with nServiceBus 1.9".
Getting Ready: Install an SVN Client
[ Note: If this is your first time working with nSeriviceBus, ensure that you install Visual Studio 2008 and the .NET Framework version 3.5 before you proceed.]
Before you begin, make sure you have about 200Mb of disk space available. You need a few Mb for the SVN client and nServiceBus, when it is built, uses about 140Mb on disk.
The nServiceBus code is hosted at SourceForge.net, the world's largest open source software development web site. SourceForge.net offers a variety of free services - the most relevant is hosting Subversion repositories - a repository is more commonly referred to as source code control. Subversion, also called SVN, uses a special client for accessing code repositories.
TortoiseSVN is a popular SVN client that I use in this article. Download TortoiseSVN for Windows from here: http://tortoisesvn.net/downloads
TortoiseSVN is easy to use and does not require configuration once you have it instlled. SVN repositories contain projects and you access a repository to get a project using a URL through TortoiseSVN. When you get files from the repository you get the latest version.
Getting the Code
Getting a project using SVN is referred to as a checkout. If you are SourceSafe or Team Foundation Server user, SVN checkout is equivalent to the 'Get Latest Version' operation so it does not lock files for editing. The SVN equivalent of the VSS or TFS checkin is Commit.
Checkout nServiceBus files by doing the following:
1. Create a new folder on your system. 2. Using Windows Explorer, Right-click the new folder and select the 'SVN Checkout...' option from the context menu.
If you don't see the 'SVN Checkout...' option in the context menu, close and re-open Windows Explorer, then try again.
3. Enter the following URL for the "URL of repository" field:
https://nservicebus.svn.sourceforge.net/svnroot/nservicebus
4. Set the Checkout Depth dropdown menu to "Fully Recursive".
5. Select the "HEAD revision" option under the Revision group (the Head revision means that you want TortoiseSVN to the most current revision).
The following screenshot details the TortoiseSVN configuration:

6. Click Ok and wait for the operation to complete.
It can take a while to download all of the code to your system, depending on your Internet connection. As I mentioned earlier, nServiceBus files use about 140Mb of disk space once the build process is complete.
Understanding The Basic Directory Structure
Once the files are on your system, browse to the folder from step one - you'll find two new folders: branches and trunk.
The trunk folder contains a copy of the code that's considered current. The code in the branches folder contains one or more copes of the code in the trunk at a particular point in time. Open the branches folder to reveal the version 1.9 branch - the code in this folder is the most current version 1.9 code that includes fixes for current bugs, new features, etc.
The rest of this article uses the trunk version but you'll get similar results using the 1.9 branch.
There are several folders under the trunk folder:
- build - hosts nServiceBus binaries
- Documentation - currently hosts a class diagram
- external-bin - hosts the binaries for supporting components like Castle Windsor, NHibernate, Rhino Mocks, and the Spring framework
- Samples - hosts nSerivceBus samples
- src - hosts source code and project/solution files
You're almost ready to start building nServiceBus - you need to setup the queues that most developers use when starting with nServiceBus. The build process does not depend on the existence of these queues. A file in the trunk folder (or the branch's folder) called 'msmq install.vbs' is a script that sets up some MSMQ queues on your system. Run the script by double-clicking it - you won't need to run this script again once the queues are setup.
Once the queues are ready, you are ready to build.
Building nServiceBus
There are several batch/command files in the trunk's main folder that simplify the build process. Start by opening a Visual Studio 2008 Command Prompt window, and change to the trunk's directory.
The primary batch files that you'll use to build nServiceBus are:
- build_without_strong_name.bat - builds nServiceBus and does not sign nServiceBus.dll
- build_with_strong_name.bat - builds nServiceBus and signs nServiceBus.dll
Building without signing nServiceBus.dll (the first build script) is good in most cases. The second script that builds and signs the nServiceBus assembly is necessary when you plan to install the nServiceBus assembly in your system's GAC (Global Assembly Cache).
There are some other batch files in the trunk folder:
- build_samples.bat : builds the samples only
- build_src.bat: builds just the nServiceBus assembly
- build_tools.batL builds only the nServiceBus tools
- clean.bat: deletes all files in the trunk's build folder
[If you want to see how the builds differ, open nant.build (an XML file) to see the nant tasks that describe the build for each target.]
I usually start the build process by running 'clean.bat' to ensure that the underlying folders in the build directory are ready. The batch files that build nServiceBus call clean.bat for you, but I ran into some problems with read-only files in some of the folders at one point, so I have made it a habit to clean and verify that the folders are indeed empty before I run a build.
Type the name of the batch file you want to run (build_without_strong_name or build_with_strong_name) and wait a few minutes for the process to finish. Some of the The output that appears on the screen also gets saved to text files in the build folder.
The build process builds nServiceBus along with the samples, distributor, and tools so that you don't need to compile them separately.
The build creates nServiceBus.dll in the trunk's build/output folder. The build\output folder also contains NServiceBus.Testing.dll, accompanying XML documenting and PDB files for each DLL.
The text files that contain some of the output of the build process are in the build folder. The text files contain the output of calling ILMerge during the builds. The text filenames begin with "output" (and have a txt extension) - these can be useful in narrowing-down the source of any problems that might occur during the overall build process.
You can reference nServiceBus.dll from your own projects, or copy it to wherever you plan to use it.
Conclusion
This article explained the currently available nServiceBus distributions, how to get the code, and how to compile the solution. Along the way, you learned about part of the directory structure, about some of the files that reside in some folders and got some pointers for getting more information about them.
The next article in this series demonstrates how to use nServiceBus' distributor to manage workload among at two to three servers.
|