Using SVN with Visual Studio
Intro
This article covers how to move your Visual Studio solutions to a Subversion(SVN) server hosted on the web.
Background
If are using Microsoft Visual Source Safe(VSS) you will eventually need to make the move to another source control system since Microsoft is no longer developing VSS and future versions of Visual Studio are unlikely to support it.
Visual Studio 2010 only supports Visual Source Safe with the installation of an update and a plug-in.
The Microsoft way is Team Foundation Server but if you develop in other IDEs or on other platforms you may want to use a single source control for all those different kinds of projects.
The two most popular are Subversion(SVN) and Git, this article covers how to move your Visual Studio solutions to an SVN hosted on the web.
In this article VisualSVN is used for the server installation of SVN and AnhkSVN is used as the Visual Studtio plug-in.
To migrate a solution from Visual SourceSafe to Subversion follow these steps:
- Install Visual SourceSafe
- Open Your Solution From Visual SourceSafe
- Remove Visual SourceSafe Bindings
- Install AnhkSVN
- Add Your Project to SVN
- Commit Changes
Useful actions once you have your code in Subversion:
1. Install Visual SourceSafe
Before you can access solutions in Visual SourceSafe(VSS) you must install it on your development computer.
- Install VSS 2005
- Hotfix VSS 2005 and VS2010
You need to install a hotfix to get VSS to be compatible with Visual Studio 2005.
This can be downloaded here http://code.msdn.microsoft.com/KB976375
2. To Open a Solution From Visual SourceSafe
- Install VSS 2005 (see previous section)
- Tools -> Options -> Source Control, you should be able to set a drop down for "Microsoft Visual SourceSafe"
- File > Open from that dialog, choose Microsoft Visual SourceSafe on the left hand side. The right will populate with VSS databases from which to choose (you may need to add yours if you have not connected to be it before), and you can browse for a solution file (*.sln).
3. How To Remove Visual SourceSafe Bindings
- Checkout the solution in VS2010 (see previous section)
- Now you need to unbind the solution from VSS, use the Solution Explorer(ctrl+w, s) to make sure that the solution file is selected
File > Source Control > Change Source Control...
- In the dialog unbind all the projects and solution, tick all the items then click Disconnect
4. Install AnhkSVN 
AnhkSVN is a Subversion plug-in for Visual Studio, this allows you to let Visual Studio take care of file interactions with SVN for you. You can
download AnhkSVN for search for it using the built in extension
manager Tools > Extension Manager....
Once installed you can switch Visual Studio to use AnhkSVN for its source control by Tools -> Options -> Source Control,
you should be able to set a drop down for "AnhkSVN - Subversion Support for Visual Studio"
5. To add a project
- Create your project in Visual Studio
- Create a repository
- Logon to your server via remote desktop or equivalent or use the VisualSVN remote administration tool
- Open the VisualSVN Server application
- Right click Repositories > Create New Repository...
- Tip : Enter the name prefixed with "VS_" for Visual Studio (so that we can tell which repositories are
managed from Visual Studio) you do not need to do this, it is just something that I find useful.
- Do NOT tick to create default structure
- In Visual Studio
- If you have not done so already switch Visual Studio to use SVN instead of VSS : Tools -> Options -> Source Control, you should be able to set a drop down for "AnhkSVN - Subversion Support for Visual Studio"
- File > Subversion > Add solution to Subversion...
- Choose/type the repository eg http://svn.your-dns.com/svn/VS_your_project (this is the URL to the repository that you created in the previous section)
- Tick the checkbox to create the trunk folder
- Click "OK"
- On the next form enter a comment eg "Initial Import"
- Finally commit the changes (see next section)
6. How to Commit Changes
- Use the Solution Explorer(ctrl+w, s) to make sure that the solution file is selected
- File > Subversion > Commit...
- Type a comment and click "OK"
How to create a branch
- In Solution Explorer right click the solution file Subversion > Branch Solution...
- In the "To URL" after the repository name type "/branches/[branch_name]" eg http://svn.your-dns.com/svn/VS_your_project/solution_name/branches/test_branch
- Choose HEAD
- Choose to Switch to branch if that is what you intend to work on afterwards
- Add and comment and click "OK"
How to switch between branches/trunk
- Make sure all changes are committed
- In Solution Explorer right click the solution file Subversion > Switch solution...
- In the "To URL" after the repository name type the path to the trunk, branch or tag you want
eg http://svn.your-dns.com/svn/VS_your_project/solution_name/trunk
or http://svn.your-dns.com/svn/VS_your_project/solution_name/branches/test_branch
- Click OK
How to Open a Project From SVN
- File > Subversion > Open from Subversion...
Or File > Open > Subversion Project...
- Type the URL to the repository in the URL: text box
Eg http://svn.your-dns.com/svn/VS_your_project/solution_name
- Navigate to the .sln file and double click it
- Click "OK" and a new dialog will show
- Edit the Local Directory if you want, for example "C:\SourceControl\solution_name"
|