Friday, June 5, 2009

Developing with Visual Studio & Subversion (Part II)

In the previous post we covered the installation and configuration of CollabNet’s Subversion Sever. Now, we’ll see how to install the client and Visual Studio plugin.

Installing CollabNet’s Subversion Client.

1) Files you need: CollabNetSubversion-client-[version].win32.exe
Download it from:
You are going to have to register, but it’s free and quick.
In fact, you can download both server and client version in the same package.

2) Run the CollabNet client installation file and follow the steps (you'll be prompt to select a Destination path).
3) You may need to add the environment variables:
Go to My Computer -> right click -> properties -> advance-> environment variables
Create a System variable called SVN_EDITOR as c:\windows\notepad.exe (can be other text editor)
Verify the System variable Path and check there is C:\Program Files\CollabNet Subversion Client (the destination path of the installation). If it is not there, add it.
4) That’s it! Now, you can access any subversion repository with the svn commands in a command prompt window. You only need the IP address, port and project name of your repository and a user and password with access to it.

Some useful svn commands are:

- ls. List the folders and files that a repository folder contains.
svn ls svn://ipaddress:port/myproject
- mkdir. Allows you to create a folder or project in a repository.
svn mkdir svn://ipaddress:port/myproject
- import. Lets you copy all the files in the current folder to a folder in the repository.
C:\[project path]> svn import svn://ipaddress:port/myproject
- checkout. Makes a copy of all the files in the repository folder and its subfolders to the current path. Locate the prompt in your workspace when executing this command.
C:\[workspace path]> svn checkout svn://ipaddress:port/myproject
- delete. Be careful with this one. It allows you to delete all the files and subfolders in your repository folder.
svn delete svn://ipaddress:port/myproject
- help. This one will assist you in the usage and syntax of other svn commands.
svn help [svn_command]

To look for more commands, I recommend you to go to this post.

Installing Subversion plugin for Visual Studio.

We’ll use AnkhSvn plugin from CollabNet in order to execute svn commands from the Visual Studio IDE.

1) Files you need:
Download it from:
Select CollabNet Desktop - Visual Studio Edition v1.3 for Visual Studio 2005 or 2008

Microsoft WSE 3.0.msi
You also need Microsoft Web Services Enhancement 3.0 for Microsoft .NET
Download it from

2) Install WSE 3.0, first. Just follow the steps.
3) Install AnkhSvn-[version].msi. Just follow the steps.
4) That’s it! Now, to test, open your Visual Studio and open an existing project.

Browsing the repository and Checking out a project.

5) Go to View->Repository Explorer
6) In the Repository Explorer, press Add a new URL to the Repository Explorer. Type the IP address and port of your repository. You may be prompt for your user name and password.

7) Select a folder in the tree and press Checkout from Subversion.
8) Now, just select a local folder where the files are going to be stored and press OK. You successfully checked out your code from Subversion using Visual Studio.

Adding a Project to Subversion.

9) In the Solution Explorer, right-click the solution or a project you want to add to Subversion.
10) Choose a project name, select a folder in the repository to store your solution (or create a new one) and you may check the Add trunk Folder to Project option.
11) Type a comment and that’s it!

Updating code, Committing and Reverting changes using the IDE.

You will notice the blue plus sign in each file of the solution. This means addition of files. You will see different symbols indicating that a files is equal to the repository version (green), that some changes has been made to the file and needs to commit (red), etc.

To commit a change you can right-click the file and select Commit or go to View-> Toolbars-> Source Control – Subversion to display the Pending changes window. Here you will see the summary of the changes made by you.

From this tool window, you can do almost everything with Subversion. You can Commit all or selected changes and Update your code to the recent version (in case someone else modified it). To undo a change you can right-click the file in the Solution Explorer and select Revert. That will rollback to the more recent version of the file.

So this is it for Subversion and Visual Studio. I hope it helps you and your team. CollabNet’s tools are very good, easy to install, and the best of all: they are free.

No comments:

Post a Comment