Introduction
Though I've been programming computers as a hobby since 1980, most of this was done on single machines by myself. Needless to say, I've lost work due to hardware failures, inadvertent deletion, and just plain "breaking" my working code. Ultimately, this created too much extra work and sweat.
In this article I'll describe how to transition from simply saving your code in folders on your computer, to using a revision control system which should safeguard your code and allow code "tinkering" without destructive or irreversible consequences.
Background
While there are many articles about how to set up and use a source code control system, I found many were limited, dated, or uncompleted; or they dealt with a much larger team approach to coding. This article attempts to translate my lengthy research among this mire into a helpful article suited to those entering the year 2009.
Getting Started
For the purposes of this article, I'll assume the following:
- You are NOT independently wealthy (you do not have the capitol to invest in enterprise development solutions).
- You already have Visual Studio 2008 (not Express) installed and running on your Vista machine. (Where all your hard earned cash has been invested)
- You already have personal code you work with using VS2008 and are storing it on your computer. Perhaps some source code you found online and have modified.

The tools used for this project are:
- VisualSVN Server - SVN web server to handle requests across HTTP connections
- TortoiseSVN - Windows Explorer context-menu based SVN utility
- AnkhSVN - VS2008 SVN add-in utility
There are many alternatives to these tools. In fact, all three duplicate the majority of each other's SVN functions since all include "Subversion". I've chosen them for no particular reason, though all are freely available, seem to be in growing use, and support current software versions. I'd recommend going ahead and downloading a recent copy of each to be installed using the guidance below.
For the purposes of this article I'm using:
- VisualSVN Server v1.6.2
- TortoiseSVN v1.5.5, Build 14361
- AnkhSVN v2.0..5250.202
(Note: if you follow the pictures too closely, you'll notice my server name is "Dad", my Vista installation is on my I:/ drive using my H:/ drive for storage, and the project I'm using is the SourceOutliner powertoy available at CodePlex.com)
SVN Source Control Concepts
Before we begin, it's helpful to understand what we'll be doing and why we're doing it. Here's where my biggest struggle began. Perhaps you've already interacted with CVS or even SVN code repositories online at places such as SourceForge.net. But if you are like me, you didn't go any deeper than "checking out" code to download it to your computer and fiddle with it.

Though not the best example, a code repository is like the old "Briefcase" file on the Windows95 desktop (did anyone ever really use it?) The code repository is a storehouse containing the code files and all modifications to those code files, along with who modified them and their comments. Subversion (SVN) programs perform the interaction and record-keeping. Specifically, there are no folders or files within the repository when viewed using the file system. However when using a Subversion program, it accesses the repository and displays the database as if it were a file system.

The code repository is simply a database filled with records. It can be acted on via the local file system or remotely via HTTP. Therefore, an SVN Server is a web server that handles interaction with the code repository across HTTP and uses its built-in Subversion to track all changes. It also acts as a database server in that respect since it regulates tracking of revisions. The SVN Server is a portal through which all code file changes go in and out of the code repository.

And finally, TortoiseSVN and AnkhSVN are graphical interface utilities which contain Subversion and also allow interaction with an SVN Server instead of using command-line utilities. While TortiseSVN is integrated into the Vista file system (namely the Windows Explorer), AnkhSVN is integrated inside VS2008.

(Sidebar discussion: To reach the results of this project, the SVN server is not really needed, nor is TortoiseSVN once we create a repository with one of them. However, my goal is to acquaint us with how SVN works across the internet using remote servers. It just so happens for our project, our local and remote workstations are one and the same. Generally, every place we access the SVN server using https:// we could just as easily use file:/// and access a local repository on our computer or the Windows network.)
Setting Up the VisualSVN Server
First we'll make plans to install the VisualSVN Server on our Vista machine, then we'll install it.
I keep my personal source code stored in the default VS2008 "projects' folder found at "C:\My Documents\Visual Studio 2008\Projects." This is not going to change.
Next we must choose where we'll host our code repository. Though I'm breaking rules by keeping all this on the same computer, I'd at least recommend your keeping the repository on a separate partition or separate hard drive. (Even better yet, on a separate Win32 box using it as a file server, but that's beyond the scope of this project). We'll use "D:\SVNRepository"
Then we must choose what type of security we'll use, it has two parts. Since the SVN Server is a web server, the first part we must decide is if we want a secure connection to the svn server (https://) including how to avoid conflicting with an existing IIS7 web server. We'll go with a default secure connection using the default settings which can be changed later. For the second part we must decide how users authenticate with the server. We'll choose windows authentication since its better integrated.
Now's the time to install the VisualSVN Server using the details decided above.

When the installation is complete, you should have the VisualSVN Server Manager displayed. Before we can actually access this server, we'll first need to add some users. Right-click on the "Repositories" item in the left pane and select "Properties." Add our user name with read/write permission. We also might want to add "Guest" read only permission.

Next we'll create a code repository which is a folder inside our main repository. In our case, we'll use a single repository to store all our projects by a project name folder. We can always add or reorganize later. We can either right-click on the "Repositories" item in the left pane and select "Create new repository..." or choose that item if it's displayed in the main right pane. We'll name our repository "Main" and there's no need to create a default structure at this root level, we'll do that inside each of our projects (my layout preference)

If everything has gone well, at this point we can see our SVN repository. We can right-click on the "Repositories" or "Main" items in the left pane and select "Browse" or click on the Server URL if it's displayed in the main right pane.

For now, we've completed setting up the VisualSVN Server.
Setting Up TortoiseSVN and AnkhSVN
At this point we'll install our two graphical interface utilities. Try not to worry about the "Vista" warning when installing TortoiseSVN and just do it.
Next we'll check to see if AnkhSVN is set to work with VS2008. Launch VS2008 and select "Tools", "Options" then the "Source Control" settings. The Current source control plug-in should be AnkhSVN. If not, drop-down the list and select it. Again, if you're a fan of WinMerge, you could set it up under Source Control-Subversion. Well stick with the default AnkhSVN utilities.

Importing your code into your repository
So, if we've been successful at following up to this point, we have a running SVN server, a remotely accessible local repository, and a VS2008 interface. However our personal source code is still just sitting in our projects folder awaiting destruction from hardware failure or undisciplined code changes.
This next concept was the second biggest hurdle for me to overcome. Thankfully AnkhSVN automates most of the lengthy steps you'd find elsewhere on the web. We will continue to work with our code from the same location as we always have. However, we will begin using the SVN repository as a backup and revision management facility.
Inside VS2008, open our source code project as always. Next, in the Solution Explorer, right-click on the solution name select "Add Solution to subversion..." We'll need to use an SVN server path which includes the repository name. In my case it's https://dad:8443/svn/Main. Anything less, and it won't find the server. Select "svn/Main", and check off "Add trunk Folder for project". Refrain from creating a new folder or selecting a project already within the repository unless this is a subproject. After clicking "OK" we'll be asked for a log message, I'd suggest "Initial import into repository." We've successfully preped the project for inclusion into the repository. Note a slew of icon glyphs (yellow and blue plus signs) have been added inside the Solution Explorer.

Although the VS2008 "solution" is connected to the repository, the VS2008 "projects" inside the solution are not. In the Solution Explorer, right-click on the solution name select "Add Selected Projects to subversion..." We can connect or disconnect the solution or projects from subversion using the "File", "Subversion", "Change Source Control" menu item.
Now wait! You'd think we were done at this point...however, we're only halfway to actually adding our project to the repository. Go ahead and browse the repository. Our new project is NOT there. We've turned on source control features within our VS2008 project, but not committed it to the repository. This is actually a "feature" not an added step. What we do inside VS2008 doesn't have to affect our repository. Go ahead and exit VS2008 saving your work. As a learning point, this is what we'll be doing in the future. That is, modifying our "working copy" as we've always done. We're not required to update the repository with EVERY minor change. Restrain yourself if necessary!
Go ahead and re-launch VS2008 and open our project. Everything is as we left it! To import our work into the repository, we must "commit" it. Open the "Pending Changes" window at the bottom. You'll see the list of "changes" not yet acted on. Also notice the "Commit" and "Update" buttons at the top left of that window. These will become our most used SVN friends in due time.
- "Commit" adds changes we've made to our working copy into the repository as a new revision
- "Update" attempts to update our working copy to the latest version in the repository

We'll deal with possible conflicts between our working copy and the repository in another article. For now, we know our project is not yet in the newly created repository, so click the "Commit" button to import it there. Notice all the files listed in the pending window disappeared and the "Commit" and "Update" buttons are no longer enabled. Congratulations, our working project is in sync with the repository. Verify this by browsing your repository. We may have to refresh the page or management console to get it to display the updates. If we browse our project's working folder in Windows Explorer, we should notice the files and folders now have glyphs similar to what's inside VS2008 thanks to TortoiseSVN. We'll also notice "_svn" folders containing our local source code control information.
Conclusion
We've gotten SVN up and running locally and learned how to adapt VS2008 projects to SVN source control. In part II, we'll learn how to work with changes to our source code and how the repository can be our friend.
In summary in this article we:
- We installed an SVN server and utilities
- We created a local SVN repository which can be accessed remotely
- We added Source Control features to a programming project and then added it to our SVN repository
Tweaking your setup
Since VisualSVN Server is a graphical interface to a Win32 version of the Apache web server, we can easily modify the configuration.
To tweak the SVN browser display and allow easy interaction with TortiseSVN and Windows Explorer, see this article: Customise VisualSVN Server browser view On your Vista machine you will need to install the WebFolders feature and set up a "Network Place".
Credits and References
Here's some additonal references to better understand and use SVN.
History
- Nov 24, 2008 - Removed note to change TortoiseSVN setting since it only applies to VS.Net 2003.
- Nov 22, 2008 - Began working on my first article for CodeProject. it may need corrections to add additional steps when installing on a clean machine.
| You must Sign In to use this message board. |
|
|
 |
|
 |
Hallo Dave, I'm newly registered here just for the possibility to say thank you! The SVN solution works great. I have installed client parts on Win XP Pro with no problems! (Server is on Win 2008 Standard running on Hyper-V)
So, let me please you to use url to this article on my website to inform my collegues in Czech republic? All they in my neiborgh are fighting with Visual SourceSafe strolngly and loosely, but this helps!
Thank you once again
Vlado
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
 |
Hi All, Our team is currently using tortoisesvn to work together on the project.But,Can anyone tell me how to disable the locking/stealing of locks for client users or may be allow this facility to the named administrator. The documentation by collabnet suggests that it is possible through hook-scripts but not how to do that.I searched every where on net but didn't find the suitable solution. Can i do the required stuff from VisualSVNServer.
For your Information we are using 1>TortoiseSVN 1.6.1 2>AnkhSVN for Integration with VS2008 3>VisualSVN Server for the repository browse
Help me. Thanks In Advance. Ashwani Singh Senior Software Engineer EBC Publishing Pvt. Ltd
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
I will probably need to use this to meet my requirements (i.e. two developers, remote locations working on the same VS project). And at that point I'll be damn glad that you took the time to write this article.
I was just wondering though if you'd run across anything simpler in your "travels?" I'm looking for something that allows file check out/in in a networked environment (we're connected via VPN). Ideally this would be something that is very client centric in terms of where the intelligence for the system lives.
For example, I'm thinking in terms of an SQLite DB on the host with a few extensions with clients all processing remotely. The DB either contains the file in a BLOB table or lets the project sit somewhere, all the while watching it carefully.
The advantage is that this holds the promise of stupid simple setup, with capability that will support small to mid-sized projects. Drop it down on top of any networked environment and off it goes.
WAIT the alarm's ringing! It must be time to wake up...
Thanks again for what will likely prove to be a great help.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
 |
GOod art5icle, I used tortise beofre but never AnkhSVN, I will look into it. I am readin this so I can read your seoond article. good work.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
 |
Hi! I want to create a VisualSVN Server for remote access. I have a dynamic IP, so I use No-Ip, a dynamic DNS service.
Can anyone explain me how can I configure this?
Thanks in advance.
Best regards,
Mike
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Hello
First of all thanks for this great article.
I came accross a problem and it began after I've installed AnkhSVN. I think it can be related since the only solution to resolve it was to uninstall AnkhSVN.
After installing the programs on 2 machines the same problem occurs:
The Data Sources disappear from the Data Sources windows and I had to either close the solution or Visual Studio to get them back. But it worked for a small time and then they started to disappear again. They were not lost. Only nvisible and unusable.
I've tried to google for some solutions but found nothing that seems to work.
As a last resort I (finally) remember that it started soon after installing AnkSVN, uninstalled it and the problem disappeared. I reinstalled AnkhSVN and the same problem restarted. I uninstalled it and it stopped again. I tried then VisualSVN and the problem does not occur.
It seems that with AnkhSVN installed the Data Source window doesn't refresh and causes the problem.
Has anyone expereinced this or know about a setting that can be causing it ?
Thanks in advance (and sorry any english mistakes it's not my natural language).
Carlos das Neves
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Hi Carlos,
Can you please contact the AnkhSVN project with your issue so we can try to resolve it for the next release. (The information in your message doesn't have enough information for me to reproduce it here)
The easiest way to contact the AnkhSVN project is via users@ankhsvn.open.collab.net.
You could also try the AnkhSVN daily builds to check if your issue is already resolved. The most recent daily build (and a changelog) is always available on http://ankhsvn.net/daily/.
Thanks, Bert (One of the AnkhSVN developers)
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Hi, Thank you for a very helpful article. I have a question: My webserver is pointing to wwwroot - If I check in files from my local machine to a repository on the web server, do I have to login to the web server and manually copy files to wwwroot?
Or, to ask the question differently, How do I set up the web server so that when I check in my files, the directory iis uses is updated automatically?
Regards,
Sam
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
I'm new to this also, and I'm a little confused by your question but let me take a shot. The VisualSVN actually starts a version of Apache (that uses relatively low resources). Now, when you check files in either with Visual Studio or a subversion client, it talks to the web server and transmits the files over HTTP. Those files are then stored by the Web Server/VisualSVN service in a database that you specified when you setup VisualSVN. There's no need to manually copy anything to the web server and to be honest, I'm not sure you can even do that (I believe it uses BerkelyDB as a backend).
For backups, I'm fairly certain you can just xcopy that directory onto another storage medium at night, that's at least what I do and I haven't had any problems.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
1.) I set up a web server with an OS and IIS only. No source code on the web server. 2.) I create a repository on the web server. 3.) I create default.aspx on my local machine and check it in to the repository on the web server. 4.) I create a web site on the web server. I need to point the server to a copy of default.aspx. How do I do that? Default.aspx is still in the repository. Do I need to copy it to wwwroot manually?
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
 | DLL's  lucasstark@gmail | 6:58 15 Dec '08 |
|
 |
Where do you keep the complied assemblies when using a Source Server like this? I want to be able to ensure that my team members can use the release build of an assembly. I am thinking about using an XCopy post build event durring my release configuration to copy the DLL to a network share. Then with visual studio, I would add a reference to that location.
Thanks,
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
I would be interested in a complete snapshot of a release. Currently, we are using Externals with a given project (4 or 5 components) and then create a tag. Update the tag to grab the current source to the workstation and then remove the externals from the tag (if we don't remove the externals from the tag then future updates cause the tag's to update to the head revision). This gives me the source code for a given tag. But, eventually we won't need the externals once the components are in a stable (maintenance only) release. At that point, a compile and xcopy to a versioned build folder is a good bet!
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
I use this at home (because it's free, low resources and works well) and SourceGear Vault at work. With SourceGear, you can put the assembly in the source repository and the "share" it so all references point to the single source, then you can do a "get latest version". I don't know if this includes the same functionality as I've only been using it for a few weeks but it may exist. If not, I suppose you could include it in each project and update them in the source repository, but that's rather cumbersome. Your solution would work also.. then they can toggle the setting to have it copied locally or they can reference a local copy and have a prebuild event that gets your network copy.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Much thanks for this article, it was highly useful. I love working with source control, love having it intergrated with the client and this provides both with a low overhead implementation on the server side (from what I've seen so far... I have it running on an old PIII 450 with 256MB of ram in my basement with an external hard drive attached for backups and it's working very well).
Kudos to you and much thanks for sharing the tutorial.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
|
 |
|
 |
you mentioned that you have to enable the _svn dirs instead of the .svn ones.
That's wrong! As the tooltip clearly states, this is only required for VS2003 (because of a bug in that VS version). Subsequent VS versions have that bug fixed and don't have problems with the .svn folders at all.
|
| Sign In·View Thread·PermaLink | 5.00/5 |
|
|
|
 |
|
|
 |
|
 |
The last time we evaluated, I found VisualSVN much better than the free, IIRC, AnkhSVN.
The license costs are really low, so we all use VisualSVN as the VS.NET plug-in of choice.
modified on Sunday, November 23, 2008 4:07 AM
|
| Sign In·View Thread·PermaLink | 3.22/5 |
|
|
|
 |
|
 |
Uwe Keim wrote: The last time we evaluated, I found VisualSVN much better than the free, IIRC, AnkhSVN.
Personally, I'm using AnkhSVN on a regular basis and I'm not unhappy or especially happy with it. I'm using it because it's free of charge, but I agree with you that license costs do not really matter here. I hear this VisualSVN is better statement not for the first time now, so I'm curious. Could you give me some details or point me to some relevant material?
Thanks Thomas
www.thomas-weller.deProgramming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. Programmer - an organism that turns coffee into software.
|
| Sign In·View Thread·PermaLink | 5.00/5 |
|
|
|
 |
|
 |
No resources to point to, my own experience was that Ankh was somewhat strange in behaviour (don't recall details, too long ago) and it seemed (seems?) that the active development of Ankh was paused/halted.
So I prefer an actively developed product.
|
| Sign In·View Thread·PermaLink | 2.33/5 |
|
|
|
 |
|
|
 |
|
|