Friday, October 26, 2007

SVN Integration in Visual Studio with AnkhSVN

On the heels of the aforementioned fantastic tool SVNOneClickSetup, I discovered AnkhSVN, a Visual Studio add-in that integrates Subversion version control.

Get it here:
http://ankhsvn.tigris.org/

These two tools combine to make a version control solution that's incredibly easy to configure and use. I've never used Subversion before in my life, and within 20 minutes I remotely set up my home server, had 2 projects in my repository, and had 2 remote client PCs connected and able to check out & commit. Try doing that with a VSS 6.0 or 2005 server setup.



The problems I ran into were pretty minor; Tortoise doesn't like to copy folders recursively when dragged into a repository from Windows, and getting VS & Ankh to recognize version control bindings didn't work exactly like I thought it would. Before you jump in, here are a few tips to get you past the initial snags you might encounter:

  1. AnkhSVN's Visual Studio integration magically seems to work better if you install the latest version of TortoiseSVN first.
  2. When you install SVNOneClickSetup, do let it create the default project that it wants to. Name it something like "ProjectTemplate" and leave it exactly the way the installer creates it; it will created tags, branches and trunk subdirectories for you.
  3. When you want to create a new project, first use Tortoise to make the directory: hit Start -> Run -> [ svn://your.svn.server:3690/ ] (or whatever port you're running it on). In the TortoiseSVN browser, right-click your "DefaultProject" folder and select "Copy to." Enter svn://your.svn.server:3690/YourNewProjectName.
  4. Now open your solution in Visual Studio; right-click the solution node in Solution Explorer, and select Ankh -> Add solution to Subversion repository.
  5. Put the solution at svn://your.svn.server:3690/YourNewProjectName/trunk.
Now when you want to fetch a solution onto a new PC, use Visual Studio, selecting Tools -> AnkhSVN -> Checkout a repository directory. In SVN, "checkout" means something more more like "get latest" does in VSS or TFS. Now Ankh should spot the bindings when you open the solution. Use "lock" on a file to do what VSS & TFS mean by "checkout." However, editing doesn't require locking; locking will just block check-ins ("commits") by other users.

Enjoy!

No comments: