Does Anyone Know of a Good C# API for Subversion

Does anyone know of a good C# API for Subversion?

Have a look at SharpSVN. This is an open-source binding of the Subversion Client API for .Net 2.0 applications.

For example, this library is used by the AnkhSVN Visual Studio Add-In.

Is there a Subversion API that can be used to program against in .NET

Svn.NET is a continuation (fork) of SubversionSharp mentioned in CMS's answer. SubversionSharp is limited to the .NET 1.1 platform.

Svn.NET supports the following platforms:

  • .NET 2.0 on Windows Platforms
  • Mono on Win32 (2.0 framework)
  • Mono on Linux (2.0 framework)

Are there Windows API binaries for Subversion or do I have to build SVN to call the API from Windows C++?

You need the dev (e.g. svn-win32-1.6.16_dev.zip) package from here. Probably download also the binaries (e.g. svn-win32-1.6.16.zip) of the tools (DLLs are there).

A viewer for subversion

If you want to include SVN-based functionality into your software, you might want to use

  • sharpsvn

It's licensed under the Apache License, so you can use it in commercial projects (with some conditions, read the license for details). I have no personal experience with it, so I don't know if it already includes a viewer component or just the bare SVN client code. In any case, the front page lists a lot of open-source projects built upon sharpsvn, maybe one of those would be a suitable candidate for inclusion in your software (if the license fits your needs).

How to programatically do file versioning with SVN and .NET?

You should take a look at the SharpSvn .NET library. You will probably need checkout and commit commands:

Checking out:

string wcPath = "c:\\my working copy";
using (SvnClient client = new SvnClient())
{
client.CheckOut(new Uri("http://server/path/to/repos"), wcPath);
}

Committing:

string wcPath = "c:\\my working copy";
SvnCommitArgs a = new SvnCommitArgs();
a.LogMessage = "My log message";

using (SvnClient client = new SvnClient())
{
client.Commit(wcPath, a);
}

Best strategy to write hooks for subversion in Windows

I’ve just spent several days procrastinating about exactly this question. There are third party products available and plenty of PERL and Python scripts but I wanted something simple and a language I was familiar with so ended up just writing hooks in a C# console app. It’s very straight forward:

public void Main(string[] args)
{
string repositories = args[0];
string transaction = args[1];

var processStartInfo = new ProcessStartInfo
{
FileName = "svnlook.exe",
UseShellExecute = false,
CreateNoWindow = true,
RedirectStandardOutput = true,
RedirectStandardError = true,
Arguments = String.Format("log -t \"{0}\" \"{1}\"", transaction, repositories)
};

var p = Process.Start(processStartInfo);
var s = p.StandardOutput.ReadToEnd();
p.WaitForExit();

if (s == string.Empty)
{
Console.Error.WriteLine("Message must be provided");
Environment.Exit(1);
}

Environment.Exit(0);
}

You can then invoke this on pre commit by adding a pre-commit.cmd file to the hooks folder of the repo with the following line:

[path]\PreCommit.exe %1 %2

You may consider this overkill but ultimately it’s only a few minutes of coding. What’s more, you get the advantage of the .NET language suite which IMHO is far preferable to the alternatives. I’ll expand my hooks out significantly and write appropriate tests against them as well – bit hard to do this with a DOS batch file!

BTW, the code has been adapted from this post.

i have to access/commit/update SVN repository in WPF application using SVN API or libraries

SharpSvn was desiged for .Net 2.0 and Subversion 1.5 and later. It integrates all subversion dependencies in a single set of dll that is directly usable from .Net (XCopy deployable). One of the other strong points of SharpSvn is that it hides all memory management and transforms Subversion errors in exceptions, and more importantly vice versa. (Makes debugging callbacks very easy)

NSvn was used by AnkhSVN before AnkhSVN 2.0. It moved to SharpSvn after that.

The IronSvn project on Codeplex closed down. (It suggests using SharpSvn).

Svn# and its 2.0 successor Svn.Net are plain wrappers of the Subversion C api. They required the binaries of a subversion release to work. And you must manage the apr pools and some of the apr collection marshalling yourself from managed code. This is the only cross platform solution in this list. (Works just as well on linux)

Automating Subversion with C#

How about sharpsvn



Related Topics



Leave a reply



Submit