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.

Thursday, June 4, 2009

Developing with Visual Studio & Subversion

A reliable Version Control System is important to every development team. Generally speaking, Java developers are very familiar with CVS and Subversion, but .Net developers often use Microsoft SourceSafe to manage their code. However, SourceSafe is pretty bad. I see SourceSafe as a source code backup system more than a version control system (doing that, it really makes justice to its name).

So when I tried to make the jump to Subversion, I encountered a couple of issues. Now I’m posting this Tutorial about how to implement Subversion in .Net developments, just in case you need it.

In this tutorial we are going to use CollabNet products: its Subversion Server and Client and AnkhSVN subversion plugin for Visual Studio. I will use Visual Studio 2005, but it works for 2008, too.

First thing to do: install the Subversion Server.

1) Files you need: CollabNetSubversion-server-[version].win32.exe
Download it from here:
You are going to have to register, but it is free and quick.

2) Run collabNetSubversion installer and follow the steps.
You can use a server or just your local PC. It depends on the size of the team and the resources you have.

3) Select to install both components SVNSERVE and Apache (MOD_DAV_SVN) (Apache 2.2).

4) Select the port (default 3690, you may use this one) and a repository path (default c:\svn_repository) and select install svnserve to run as Windows Service.

5) Select Host for Apache (localhost or your IP) and host port (default 80, if IIS is installed or the port is already assigned select other, like 3128) and select install apache to run as windows service. Select the repository path for mod_dav_svn (the same as step 4) and the repository location prefix (default /svn). Enable viewVC is not necessary.

6) Select destination folder and click install.

Until this step, we already installed CollabNet’s Subversion Server, but we still have to do some configurations.

Configuring the Services

7) Open the Services tool (Administrative Tools->Services or Start->Run...->services.msc).
8) Look for Apache2.2 service and start the service.
9) Look for Subversion Server and start the service. You can see in the Properties of the service if the start up type is set to Automatic.

Setting Environment Variables

10) Go to My Computer -> right click -> properties -> advance-> environment variables.
11) Create a System variable called SVN_EDITOR as c:\windows\notepad.exe (or you can choose another text editor).
12) Verify the System variable Path and check there is C:\Program Files\CollabNet Subversion Server (the destination path of the installation). If it is not there, add it.

Creating the Repository

13) Open a Command Prompt.
14) type:
svnadmin create c:\svn_repository (the repository path you entered in the installation).
15) Navigate to c:\svn_repository and verify that a lot of files have been generated there.

Creating Users and Granting Access

16) Navigate to the c:\svn_repository\conf\svnserve.conf file and open it with notepad.
17) Uncomment (remove the # sign and the first blank space) the following lines:
anon-access = read
auth-access = write
password-db = passwd

18) The password-db variable is the file where the passwords are stored. Go there (c:\svn_repository\conf\passwd) and open it with notepad.
19) Uncomment (remove the # sign and the first blank space) the following lines:
[users] harry = harryssecret sally = sallyssecret
20) "harry" and "sally" are your user names with their passwords. You may delete them and create your own user names.

Creating a Project

21) Open a command prompt and type:
svn mkdir svn://ipaddress:port/myproject
Where "myproject" is the name of your project, "ipaddress" can be replaced with your IP address or "localhost" and "port" with the subversion server port.
22) Your notepad (or favorite text editor) will prompt you to add a comment. Add it, save it and close the window.
23) Now you'll be prompted for credentials. You may need to enter the password for your PC user account, then use harry or sally's username and password (or the ones you created).
24) Create the folders that by convention should be in a subversion project:
svn mkdir svn://ipaddress:port/myproject/trunk
svn mkdir svn://ipaddress:port/myproject/branches
svn mkdir svn://ipaddress:port/myproject/tags

25) Finally, to test that everything is OK, run this command:
svn ls svn://ipaddress:port/myproject

So far, you already set up a Subversion server, a repository with its users and a project.

In the next post we’ll see how to install and configure a Subversion client and a plugin for Visual Studio 2005.

Useful links about this topic: