Wednesday, January 25, 2006

Setting up Subversion in VS.Net/Windows environment

Setting up Subversion in VS.Net/Windows environment

This short article is just about client side setup, for server side installation, here is a real good article from Miguel Jimenez’s blog.

we’ll need the following softwares:

  1. TortoiseSVN, a Subversion Administration interface that integrates with Windows Explorer as a Shell Extension.

  2. RapidSVN, a GUI Subversion Client application if you don’t prefer shell extension.

  3. AnkhSVN a Subversion addin for Microsoft Visual Studio .Net

This article is based on my experience with TortoiseSVN- , Ankh 0.5.5 and VisualStudio .Net 2003 on WindowsXP.

1, install TortoisesSVN, should be painless without any difficult setting to do.

2, before we begin with any project, let’s do some settings in TortoisesSVN, right click on any where in an windows explorer, select TortoisesSVN ( settings. In the general page there is a textbox called Global ignore pattern, if you are mostly working with .Net projects, you can set this setting as the following:
*.tmp *.bak */bin */obj bin obj *.~?? *.suo *.user *.webinfo */CVS CVS *cvsignore* *resharper* .#* *ReSharper* Ankh.*Load
All the files whose file name conforms to these pattern will be ignored by SVN.
Of course you can add or remove patterns, just use space to separate them. Click OK to apply the change.

3, now we can bring a project under control (for project that is already on the server, you just need a simple checkout ) I assume that a repository is already setup on the server. Say you have a project called MyProject

  • Right click on any where in an windows explorer, select TortoisesSVN ( Repo-browser. In the Repository Browser, right click on the folder where you want to place you project ( commonly YourRepositoryName/trunk ), select create folder. Enter “MyProject” as the name. Then click OK to exit.

  • Use windows explorer to browse where your project located ( Visual Studio Projects\MyProject\), within the project folder, right click on blank and select SVN Checkout. In the url of repository enter the url of the folder you just created, for example: svn://, and click OK. You will get an alert window, saying the target folder is not empty! Blah blah… click Yes. Then Tortoise will do a real quick checkout, and create a “_svn” folder in the project folder.

  • Now if you right click on blank space of your project folder in windows explorer, you will see the SVN Commit option, click it. In the popup commit window make sure you check everything you want to include in the control and uncheck everything that you don’t (for example web.config/ App.config). click OK and go get a cup of coffee.

  • After committing is done, under the project folder, select SVN commit again, this time you will see all the items that you don’t want to be included in the source control, select them and right click on them chose ignore then you can select to ignore the file only or all the files with the same extension.
Done with the TortoiseSVN part, lets go to the addin AnkhSVN

4, After installed AnkhSVN, open, go to Tools( AnkhSVN ( Edit the AnkhSVN config file, you will see the configuration file, at the end of the file you will see a sentence
<!-- <AdminDirectoryName>_svn</AdminDirectoryName>-->
If your TortoiseSVN is using _SVN as the adminDirectory please
uncomment this sentence so it becomes:
This way the AnkhSVN will work with TortoiseSVN well.
Now open you project, AnkhSVN will popup a messagebox saying it has detected that this project is under the Subversion Control, do you like to enable AnkhSVN for this project. Off course, click yes.

Now you will be able to commit or update in the, if you add/remove something, it will also be automatically add/removed to/from the Subversion. You just need to commit the whole solution. Sometimes you will see question mark which probably means that some new item is unknown, please update or add or ignore that item.
If you want to get to some file out of version control without losing it, please do the following:

  1. Move the file to somewhere safe, not inside your working copy.

  2. TortoiseSVN → Commit the parent folder. TortoiseSVN will see that the file is missing and you can mark it for deletion from the repository.

  3. Move the file back to its original location.

  4. Add the file to the ignore list so you don't get into the same trouble again