I wanted to release binaries of my projects and embed the SVN revision and branch version number in them automatically. When it comes to build automation in .NET, MSBuild and MSBuild Extension Pack are the way to go. SVN isn’t supported out of the box, so I would have had to write targets that invoke the SVN command line tools. Tedious and ugly work. And then I had the idea that since MSBEP is open source, maybe I can develop support for SVN in it, so that my life will be easier, and also the whole world can benefit from that as well. My idea was very welcome by the project leader, Mike Fourie, so I joined the project and did it. See the official announcement here.
It is planned to be released this March, as version 126.96.36.199 and 188.8.131.52. Technically, it was quite and easy development, but it felt awesome to contribute to a project with such a high reach. It was also the first project where I used StyleCop and FxCop. I think StyleCop is a pain in the ass and I never want to use it again. I’m used to formatting my sources quite often with the Visual Studio menu command, and I always take special care to make my code look nice by default, so I’m better off without StyleCop’s crazy, crazy rules. FxCop, on the other hand, is really awesome, I even feel dumb that I’ve never used it before. I’ll be sure to use it in my projects soon.
The main source file is Svn.cs. The very first thing it does is that it searches for an SVN installation, namely the command line tools svn.exe and svnversion.exe. It checks the PATH first, so that users can set a preference. It also searches for Cygwin, TortoiseSVN, CollabNet Subversion Client and Slik SVN, both 32 and 64 bit versions, in the registry. So even if the PATH doesn’t work, my tasks will find all of these clients quite nicely. The actual tasks execute the SVN client with some arguments, and most of them just print the output, while some others parse it with XML deserialization and present the results as output parameters. I had to amend ShellWrapper, which is used to execute commands, so that it supports printing the command output in real time. I also had to develop some utility functions.
A useful subset of SVN commands is supported without any options. It sure knows what I needed it for, and a lot more than that just to make it real useful for others. I know it’s far from complete, but I would be happy to develop it further if someone asks me nicely and it makes sense. In my next post, hopefully soon, I’ll tell you how I’m making use of these tasks, and FxCop too.