Thursday, May 19, 2011

Subversion Setup for c# Developers

At work we use TFS for everything and I hate it. I like Subversion and find it very easy to use.

I often hear that Subversion doesn't integrate well with visual studio, and that it is hard to setup and run. Well both these assumptions are wrong.

If you are running any of the windows OSes all you have to do is install SvnServer, configure it, install TortoiseSVN so you can work with svn projects from window explorer. Finally in the extension manager in visual studio and install AnkhSvn or get it here. This will give you svn support in visual studio. below will be step by step with pictures.

Svn Server install
After downloading the msi, you will be presented with some config sections. There are two that really matter. The first pictured below will ask if you want the console along with the repositories. The second pictured below will be configuration for the repositories themselves.


once installed open the console and create your first user and group. I have a group for each project. Lets add our first user. Right click on the Users folder and click Create User. Fill out the dialog with username and password.


Lets add our first group. Right click on the Groups folder and select Create Group. A dialog will display. Fill in the name and add users to it. Once done click ok.


Then add a repository by right clicking on Repositories and Create new repository. Give it a name and check the create default structure.

Then add security to the repo by right clicking on the new project and selecting All Tasks => Manage Security. Change everyone to No Access, and add the group you created earlier with Read / Write.

Thats it for SvnServer.

TortoiseSvn
Just install it and when in windows explorer you can right click on folders and there will be an added menu that allows you to do svn things, like checkout projects, update directories, commit changes and much more.

AnkhSvn
This is a plugin for visual studio 2010. To install it from visual studio go to extensions manager, click on online gallery => tools => source control and select AnkhSvn. It is free and it is awesome.

So after you create a new solution in visual studio, right click on the solution folder and select 'add solution to subversion'. Next fill in the repository url, and click ok. Thats it, it will now map your solution to your repository. Finally right click on the solution file and select, 'commit solution changes'. A dialog will open showing all modified files and gives you a chance to add a check in comment, do so and click ok. It will do it's thing and once done your project is now secure in your repository.

If you want to update your solution to the version in the repository just right click again on the solution file and select 'Update Solution to the Latest Version'. You can also select what version you want, revert local changes or anything else that is support by subversion.




2 comments:

grant rettke said...

We used the VisualSvn plugin for VS.NET at FedEx because Ankh crashed so often lol. I guess it got better?

Unknown said...

Yeah I have been using it since November and haven't had a problem with it.