How to … Access Subversion from C#

Allthough there are a lot of language bindings available for Subversion, C# is not one of them. A few resources on the internet provide some kind of binding but they are all external to the Subversion project.

With IKVM however, you can compile the Java language binding of the Subversion project to make it accessible using C#.

Here is how you do it:

Getting the necessary files

Install IKVM.NET

You can download IKVM.NET from their website. Just go to the download section and click through to Sourceforge. Select the file with “bin” in its name because that file contains the binaries. Because I used version the file was named ””. You can download it using this link.

After downloading this file, you must unzip it in some folder. This is the folder structure that will result:


Install the Subversion java language bindings

For this you must go to the Subversion website and select the “Documents & files” inside the “Project tools” item on the left. Next expand following nodes in the central tree structure:
subversion > Releases > Windows

Then look for a file named svn-win32-(version) in which (version) is of course the version. I used version 1.3.1 which is not the most recent. You can find it in the “Windows Archive” node.

The file I used had thus the name “”.

Once downloaded you unzip it into a folder of your choice. After this you end up with following folderstructure:


Using the Subversion java language bindings

Compiling the java language bindings for .NET

Copy the complete content of the IKVM.NET “bin” folder to the Subversion language bindings “javahl” folder. Like this all files are in the same folder.

Open a command window in this folder and type following on the commandline:

ikvmc svnjavahl.jar

IKVM.NET will compile the provided jar file and produce a dll with the same name. This dll contains the .NET version of the java classes.

Accessing a Subversion repository from C#

Create a console application in your favourite IDE.

Add references to the following files:

  • IKVM.GNU.Classpath.dll (which comes with IKVM.NET)
  • svnjavahl.dll (which you created by compiling svnjavahl.jzr with IKVM.NET)

Copy the following code in the project you just created:

using System;

using System.Collections.Generic;


namespace SubversionTest


    class MainClass


        public static void Main(string[] args)


            org.tigris.subversion.javahl.SVNClient svnClient

                = new org.tigris.subversion.javahl.SVNClient();   


            // replace the following string with the name of a

            //  subversion repsoitory available to you

            //  example “svn://localhost/MyProject”

            string moduleName = “<yourRepo>”;


            // replace the following string with the name of a

            //  folder available on your computer

            //  example “c:/MyProject”

            string destinationFolder = “<yourFolder>”;

            org.tigris.subversion.javahl.Revision revision =


            bool recurse = true;


            svnClient.checkout(moduleName, destinationFolder, revision, recurse);




Do not forget to replace the strings with appropriate values for your setup.

Compile the project

Copy following files to the folder containing the build results (typically a subfolder bin\Debug for the debug version or bin\Release for the release version)

  • ikvm-native.dll
  • libsvnjavahl-1.dll

Hit the Run button.
If everything went well your repository shuold be chacked out on your computer.


[1] IKVM.NET and how to convert a java application to .NET
[2] Subversion and Documents & files
[3] Online documentation for javahl classes can be viewed here


21 December 2006: original version

Building a Development Environment Part 4: make CruiseControl.NET execute and report your NUnit tests

This is part 4 in my series on managing the build process.

After seting up a source code repository in Part 1 , setup CruiseControl.NET to monitor it in Part 2 and actually produce some sourcecode in Part 3 we now will test this code to see if it works correctly.

That is what we will do in this part of the series: Create a simple library written in C# and build it automaticaly.

But first:


This post is by no means “The Way” of building a development environment. In fact, you will notice that at times I deviate from some of the practices advocated by the referred articles at the end of my articles. It’s our interpretation of the process and how we implement it. If you have any remarks or suggestions for improvement, please post a comment.
Continue reading

How to … Make Subversion ignore files and folders

Excluding files from your repository
Sometimes you may have types of files or folders in your source code tree that you do not want to include in your source code repository. Everyne developing with Visual Studio will immediately know what I mean: VS automatically makes bin and obj subfolders for your project folder in which it puts the buildresults and also creates *.suo files with your personal settings for a solution.

It would be convenient if we could exclude these files from our repository once and for all without having to manually uncheck them each time we update our project. Fortunatly, Subversion allows us to do this. In fact, there are two possibilities for exclusion.

Global exclude

With the global exclude we can exclude a certain type of file of being added to any repository to which a certain client connects. To do this, you must edit the Subversion “config” file which you can find in your local Application Data folder. A typical location for this file is: “C:\Documents and Settings\[username]\Application Data\Subversion”.

When you open this file, look for the section [miscellany]. In this section find a line with global-ignores and remove the “#” signes in front of it (if you haven’t removed them allready). Now add the files signatures you want to ignore.

For example, to ignore the suo files, we would write:

global-ignores = *.suo

Local exclude

The local excludes are made on folders. This means you can tell subversion clients to ignore a specific file, type of file or folder. This is done by setting the svn:ignore property on the target folder with the signature of the file or folder to ignore.

For example, to ignore suo files in the solution’s folder, you would perform following command in the folder of the solution:

[TargetFolder]>svn propset svn:ignore *.suo .

Do not forget the final dot, it means that the target folder is the current folder. With the above command Subversion will ignore all files with extension “suo” in the target folder.

To ignore folders we have a similar syntax. To ignore for eample a folder “bin” in our target folder execute following command:

[TargetFolder]>svn propset svn:ignore bin .

Again, do not forget the final dot, it means that the target folder is the current folder.

To ignore multiple types of files and folders, you must have a newline delimited list of values for the svn propset command. Because this can not be done with the commandline (well, I do not know how to do it anyway), we create a text file with on each line the signature of a file and/or folder to ignore.
For example, we have a textfile with following content:


We save this file in the target folder and name it “ignore.txt”, and then issue the command in the target folder

[TargetFolder]>svn propset svn:ignore -F ignore.txt .

Again, do not forget the final dot, it means that the target folder is the current folder. With the above command all folders with names obj and bin in the target folder will be ignored by Subversion.


[1] svn:ignore in the Subversion documentation
[2] global-ignores in the Subversion documentation
[3] Scott Sanders :: blog :: Ignore a file in Subversion (svn ignore) (The inspiration for making this a seperate post)
[4] svn ignore property wierdness


5 December 2006: original version