SVN With Visual Studio Express

I was looking for an integrated version control system (VCS) for my development environment.  For my needs, it had to store revisions in the cloud to easily allow me to work from multiple computers and be simple to use.  For this project, my IDE is Visual C# Express 2010 and we'll be using Google Code with Subversion (SVN) as the VCS with the TortoiseSVN client.

Google Code

I chose Google Code as my hosted VCS solution for a few reasons:

1)  It encourages (requires?) its projects to be open source.
2)  It uses my existing Google Account.
3)  It allows multiple VCS implementations (Subversion, Git, and Mercurial).


Subversion (SVN) is possibly the most popular VCS for code.  It's based on a repository that contains the current revision of code, along with all previous revisions.  To edit the code, a user checks out the latest version, updates it, and commits the changes back to the repository.  This creates a new revision automatically.  SVN keeps track of the revision of each file separately and also manages checkouts in a multiple user environment.  Wikipedia has a good overview of SVN.

Visual C# Express 2010

Visual C# Express 2010 is a free IDE for the C# programming language.  It is currently the latest version, but a new 2012 version has been announced for release later this year.

My language of choice is C# and I'm cheap, so this is the development IDE I prefer.  Unfortunately, one of the main differences between Visual Studio and Visual Studio Express is that the Express editions don't support plug-ins.  That rules out the possibility of an integrated VCS solution, but I continued to look for something that would simplify use of a VCS with Visual Studio Express.

(The setup instructions below do not use Visual Studio at all.  I mention it here mostly to indicate why I chose TortoiseSVN as the SVN client.)


TortoiseSVN is an SVN client for Windows that has shell integration (i.e. it integrates with the right-click menu in Windows Explorer).  It will work with any SVN repository and is not tied to a specific programming language or IDE.


Now let's get everything set up.  We'll assume that you already have the first revision of code created.

1)  On the Google Code website, select "Create a new project".  Enter the relevant information about the project and make sure to select Subversion as the version control system.  Click "Create project" when completed.
2)  Go to the project's website that Google Code has created.  Go to the "Source" tab and leave this page up.  We'll need some information on it later.
3)  Download and install TortoiseSVN from the creator's website.  The default options are fine for our install.  After installation, restart  the computer to enable TortoiseSVN's shell integration.
4)  In Windows Explorer, right-click on the top-level folder for your code and select TortoiseSVN > Import.  (I intuitively and mistakenly selected Export the first time.  The Import and Export commands are named from the perspective of the hosted repository.  In this case, the repository is importing the first revision of code.)
5)  An import window will open up.  Go back to the website we left open in step 2 and look for a line similar to the following: "svn checkout project-name --username".  Copy the URL beginning with "https://" and ending with "trunk/" and paste it into the URL field from the import window.  Click OK in the import window.
6)  You will now be prompted for your username and password.  Look at the website we used in steps 2 and 5 again.  Click on the " password" link to go to a website that will show your SVN credentials.  Note that this password is not the same as your Google Account password.  Copy and paste this information into the import window's login screen.  You can also select to have TortoiseSVN remember these credentials.


At this point, Google Code and TortoiseSVN are all setup with a copy of your code.  Each time you want to edit the code, there is a simple 3 step procedure to follow:

1)  Right-click in a local folder and select "SVN Checkout...".  Confirm that the URL of repository is the same as we entered previously, and then click OK.  This will create a new folder containing the latest revision of your code.
2)  Using your editor or IDE of choice, edit the code.
3)  When you're ready, right-click on the project folder again and select "SVN Commit...".  The commit window will automatically select the files that have been updated.  Click OK to begin the commit.

Now, head on over to GrokCode to learn how to use source control effectively.

No comments:

Post a Comment