Click here to Skip to main content
Click here to Skip to main content

Source Control with Visual Studio .NET

, 18 Oct 2007
Rate this:
Please Sign up or sign in to vote.
How to integrate TortoiseSVN – a Subversion Source Control system with Visual Studio .NET
Screenshot - image000.jpg

Introduction

This article explains how to integrate TortoiseSVN - a Subversion Source Control client with Visual Studio .NET. It is a "how to" cookbook that outlines specific steps needed to set up a functional Source/Version Control system to be used in a .NET project with all of the tools accessible in Visual Studio .NET. This assumes that the reader has a basic understanding of version control systems and will further research any of underlying concepts as well as the functionality of the tools on its own.

Why Do You Need To Read This?

The days of "Cowboy coding" are over both in software development methods and in dealing with the source code. If you think otherwise, you are less productive and will be less competitive than the other guy. The setup costs are not an excuse any more - the price is Free and this article will set you up and running in no time.

The article would lose in depth to any tutorial on the subject. But because it's short, there's less of a chance you fall asleep in the middle. And once you have a functional environment - you will discover the details yourself.

Background

In the core of a Source Control is Versioning functionality that allows multiple developers to work on the same project, revert to previously saved versions of a file, merge changes and more. It is essential for effective team work and also highly beneficial for single developer projects (see below on benefits for solo developers).

The most common approach for larger companies is to use Visual Studio Team System along with Microsoft Source Safe (or Team Foundation Server more recently). But for smaller projects the price of these solutions could be prohibitively high, not to mention wide dissatisfaction with Source Safe among developers community.

Open source provides excellent alternatives. Subversion (SVN) is probably the most popular version control system these days. TortoiseSVN is a Subversion client that integrates with Windows Explorer to give the user a GUI. Once TortoiseSVN is installed it can be integrating it into Visual Studio .NET as a set of External Tools. All of this comes free.

Subversion Installation

Subversion runs on any platform imaginable. But if you plan on having your repository (the central database for your source control) on your local network - then there's no need for a separate Subversion installation, TortoiseSVN will do it all (Well, almost. As Todd Smith points out in the comments you still need Subversion installed to have command-line tools). If you have offsite developers and need a repository on the Web, the easiest is to buy a hosting package for a commercial project or host it for free on SourceForge.net for Open Source projects. The commercial hosting is cheap: for under $10 a month you could get unlimited repositories, 2+GB of Web space and peace of mind. Search for subversion hosting and you'll get tons of offers. If you insist on installing it on your own, SVN 1-Click Setup should make installing Subversion with TortoiseSVN a snap.

TortoiseSVN

TortoiseSVN is no less than a marvellous peace of software. Get it here. Once installed (don't forget to Restart when it prompts you - it really needs it to be integrated with Windows Explorer), all of its options will be available in Windows Explorer from the Right Click menu.

Let's setup a working system for a Visual Studio .NET project.

Step 1: Repository Setup

First you need to setup a repository (the central database) for your project.

On the web: If you use Subversion hosting, use the interface of your hoster's control panel to set it up. After the setup you should have the URL of the repository as well as username and password needed for accessing it.

On the network: If you will use a repository on a (network) folder, creating it is a snap: Right Click on a folder > TortoiseSVN > Create Repository here... OK,OK.

Step 2: Upload Files (Optional)

If you've started with an empty repository and want to add files to it from a local folder, then locate a local folder with the files (let's say it's your project folder), Right Click > TortoiseSVN > Import…

You will be prompted for the URL of repository, enter the URL if you use hosted services or just a Windows path to repository folder if you are using a local network. For hosted services, it will also prompt you for username and password. Hit OK and your local files will be imported into the repository.

Step 3: Working Copy

Next step is to create a working copy – a local folder where you will be making all of your changes and that will be synchronized with a central repository. This will be your project folder. In this step the files (latest revision) from the repository will be downloaded to your local folder. To simplify, start with an empty folder, Right Click > SVN Checkout…

Enter URL or path to your repository, hit OK. The same files you've uploaded in Step 2 will be downloaded to your folder. SVN has also added some hidden files to this folder indicating that it is a "working copy" type of folder.

Using TortoiseSVN

Every file and folder in a "working" folder has icon overlay indicating a status of this file or folder:

When you Right Click on a "working" folder, TortoiseSVN will give you a whole new set of options:

Most commonly you will probably use "SVN Update" to get the latest revision from repository or "SVN Commit…" to upload your working copy to repository.

The focus and depth of this article make it unwise to try duplicating the wealth of documentation on how to use TortoiseSVN. Nonetheless, you still need to read a good tutorial on this. Please refer to TortoiseSVN documentation or tutorials for finer details on TortoiseSVN functionality.

Visual Studio .NET Integration

TortoiseSVN setup would work just fine with any folder including the one with a Visual Studio .NET project. If that addresses your needs, you don't have to go any further. This is a great tool and many developers use just that. But for some it may be more productive to perform the Source Control operations inside Visual Studio .NET, without going to Windows Explorer. This is done through Visual Studio .NET add-ins. Note that the add-ins are not supported in Visual Studio .NET Express editions. That's a restriction Microsoft places on them to encourage the upgrade.

For Visual Studio .NET that support add-ins, there are three choices at the moment:

  1. Simplest: Garry Broadsword's Add-on

    This is a marvellously simple and thin TortoiseSVN wrapper. Download it from Garry's Web site. In Visual Studio .NET go to Tools > Import and Export Settings… and import the settings appropriate for your version of Visual Studio .NET. You will get all of the major TortoiseSVN functionality right in Visual Studio .NET.

    The only catch is that you don't get icon overlays in Visual Studio .NET, so the status of a particular file is not immediately clear. Note though that for performance reasons some users turn off the overlays in TortoiseSVN and work happily without it. As Garry himself points out in the comments to this article:

    "...[icon overlays] used to matter for me as the files were being locked with VSS so it was important to know explicitly which files were edited. With Subversion you use "edit-merge-commit" so whilst you are making your edits it doesn't matter which files have been changed, it only matters at commit time"

    If you can live without overlays, this solution should be your first choice.

  2. Not so simple: AnkhSVN

    AnkhSVN is the most comprehensive Open Source Visual Studio .NET and SVN integration. It is not just a TortoiseSVN wrapper (in fact you don't need TortoiseSVN for AnkhSVN to work), but a separate program with functionality similar to TortoiseSVN. Even though AnkhSVN gives icon overlays and all of the tools appear right in Visual Studio .NET, the most common complaints with this beast are that it is slow on the projects with a lot of files, it has an unintuitive logic of how to update the files and one should be closely familiar with it to do what you want. If you aren't afraid of a challenge – AnkhSVN is your choice. For others with less free time on their hands – consider alternatives.

  3. Sleek, but $49: VisualSVN

    VisualSVN it is just a wrapper of TortoiseSVN, similar to Garry Broadsword's add-on. In this case more is less, architecturally these solutions are lighter and more effective that heavy weighted "all-in-one" AnkhSVN approach. In VisualSVN you get your overlays and very smooth integration with TortoiseSVN. This is simply the best choice if you don't mind paying. And even if you do, play with their trial version - you may change your mind.

Few Catches to Watch Out For

  • Right after installing TortoiseSVN do yourself a favor: go to TortoiseSVN settings and make sure that the checkbox [Use "_svn" instead of ".svn" directories] is set. For more read here.
  • Bug: VisualVSN menu does not appear in Visual Studio 2005 when installed under Windows Vista. Workaround is here.
  • When working in Visual Studio 2005 with Web sites as folders without implicitly creating a project file, the *.proj file gets created in the background in [My Documents\Visual Studio 2005\Projects] folder. VisualSVN gets confused on this assuming that your Web site should reside in the same folder.
    • Solution 1 (what I use): Before using "VisualSVN | Add Solution to Subversion…", go to "VisualSVN | Set working copy root…" to setup the proper location of your Web site. Since *.proj file stays outside of your working folder - it won't be included in commits.
    • Solution 2 (VisualSVN recommendation):
      1. Create blank solution in Visual Studio 2005 (File->New->Project->Other Project
      Types->Visual Studio Solutions->Blank Solution).
      2. Add Web site to the solution (File->Add->New Web Site) and specify
      location for it under the same root folder as solution.
      3. If the solution is located deeper than working copy root, specify
      root folder (VisualSVN->Set Working Copy Root).

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Ruslan Sudentas
Web Developer
United States United States
No Biography provided

Comments and Discussions

 
QuestionVisual Studio 2010 shows no Subversion menu PinmemberMember 107254604-Apr-14 9:32 
QuestionHow to use Gary's? Pinmembersatrio_budidharmawan8-Oct-12 18:55 
GeneralMy vote of 5 Pinmemberbluesathish13-Sep-12 2:29 
GeneralGreat article! Pinmemberdot-net-dude23-Aug-12 13:44 
GeneralMy vote of 5 PinmemberAnurag Gandhi2-Apr-12 23:11 
GeneralMy vote of 5 Pinmemberinvincibleruler12321-Jan-11 9:55 
AnswerWatchout when using local file paths when importing to a Repository Pinmemberlighttrainmedia29-May-09 15:54 
GeneralGarry Broadsword's URL moved Pinmemberospace1147-Apr-09 20:54 
GeneralLocal hosting but downloadable over internet PinmemberDarkas27-Nov-07 10:28 
AnswerRe: Local hosting but downloadable over internet PinmemberRuslan Sudentas7-Nov-07 10:47 
AnswerRe: Local hosting but downloadable over internet PinmemberKarl-Johan Sjgren14-Nov-07 21:00 
GeneralConnectivity to SVN from VS.NET Pinmembernwfrog26-Oct-07 12:27 
GeneralRe: Connectivity to SVN from VS.NET Pinmemberadimas24-Nov-07 7:13 
GeneralThe Power of Subversion! PinmemberMichael McKechney23-Oct-07 4:03 
QuestionGreat Article and some Questions PinmemberApocwhen18-Oct-07 23:59 
AnswerRe: Great Article and some Questions PinmemberRuslan Sudentas19-Oct-07 4:48 
GeneralRe: Great Article and some Questions PinmemberApocwhen19-Oct-07 6:04 
AnswerRe: Great Article and some Questions PinmemberSnakefoot22-Oct-07 22:05 
GeneralExcellent Pinmembercanozurdo18-Oct-07 6:24 
GeneralRe: Excellent PinmemberRuslan Sudentas18-Oct-07 6:31 
GeneralRepository and test server locations PinmemberRatface2315-Oct-07 21:31 
GeneralRe: Repository and test server locations PinmemberRuslan Sudentas16-Oct-07 4:35 
GeneralRe: Repository and test server locations PinmemberRatface2316-Oct-07 4:41 
GeneralRe: Repository and test server locations PinmemberRoger Bamforth16-Oct-07 5:21 
GeneralSourceSafe days have gone! Thanks Subversion! Pinmemberlonifasiko15-Oct-07 21:01 
GeneralRe: SourceSafe days have gone! Thanks Subversion! PinmemberRuslan Sudentas16-Oct-07 4:09 
GeneralRe: SourceSafe days have gone! Thanks Subversion! Pinmemberaaaabbbbccccdddeee29-Apr-09 16:27 
GeneralCowboy coding Pinmemberjdoneal15-Oct-07 10:47 
GeneralRe: Cowboy coding PinmemberRuslan Sudentas15-Oct-07 10:56 
GeneralRe: Cowboy coding Pinmemberjdoneal15-Oct-07 11:04 
GeneralRe: Cowboy coding PinmemberRoger Bamforth15-Oct-07 22:06 
GeneralRe: Cowboy coding PinmemberRuslan Sudentas16-Oct-07 4:01 
GeneralRe: Cowboy coding Pinmembergeoffeepoos5-Jul-09 18:06 
GeneralRe: Cowboy coding Pinmemberpjd100118-Oct-07 20:10 
GeneralRe: Cowboy coding PinmemberRuslan Sudentas19-Oct-07 4:42 
GeneralRe: Cowboy coding Pinmemberpjd100119-Oct-07 15:46 
GeneralRe: Cowboy coding Pinmembergeoffeepoos5-Jul-09 18:08 
GeneralRe: Cowboy coding Pinmembertrevorde stickman16-Oct-07 19:09 
GeneralThanks! Pinmembergarry_bodsworth14-Oct-07 22:29 
JokeRe: Thanks! PinmemberRuslan Sudentas15-Oct-07 5:04 
GeneralRe: Thanks! Pinmembergarry_bodsworth17-Oct-07 23:47 
GeneralTortoiseSVN "do it all" PinmemberTodd Smith12-Oct-07 11:57 
GeneralRe: TortoiseSVN "do it all" PinmemberRuslan Sudentas13-Oct-07 17:56 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web04 | 2.8.140814.1 | Last Updated 18 Oct 2007
Article Copyright 2007 by Ruslan Sudentas
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid