loads of useful information, examples and tutorials pertaining to web development utilizing asp.net, c#, vb, css, xhtml, javascript, sql, xml, ajax and everything else...

 



Advertise Here
C-Sharpener.com - Programming is Easy!  Learn Asp.Net & C# in just days, Guaranteed!

Setting up Subversion (SVN) with Visual Studio walkthrough/tutorial

by naspinski 2/2/2009 9:02:00 AM

From no source control to full Subversion support in 10 minutes - for free

UPDATE Somehow I didn't realize that VisualSVN was only a trial version (thanks for pointing that out guys!) for free :P - but, there is a great free VS plugin (ANKHSVN) available here http://ankhsvn.open.collab.net/

Now if you don't already know, SVN is a great program for keeping track of all your changes in code... and it's what all the cool kids are doing (Google, CodePlex, etc.). Your code is all kept in the repository, if you or someone wants to use it, they check it out Not to mention it is incredibly useful for teams and will save you hours/days if your coding takes a wrong turn and you need to move backwards. Bottomline is: if you are not using it, start!

There are now a bunch of free SVN providers out there, and all you really need is a client installed on your machine and you are good to go. There are a lot of great clients out there, I prefer using VisualSVN to tie together the functionality of TortoiseSVN with the UI of Visual studio (though Tortoise is great on its own as well). As for host, I actually prefer OpenSVN as ghetto as it may appear... is a quite humble site, but it is incredibly useful and FREE! Don't be fooled by its 1990 styling and clunky interface... it is there to help! Most important it is simple and to the point. Here is a walkthrough on how to set up your OpenSVN account, and get it integrated with Visual Studio 2008.

Set up your OpenSVN account

First thing is first, go to OpenSVN and sign up for your account. All you need is a project name, a couple email addresses and click Go!.

Next you will have to check your email and retrieve your password; now go back to OpenSVN, click on 'Manage Your Project' and enter your username/password.

Now that you are in take notice of the project location urls, we will need those later, also, I would recommend changing your password to something you will remember. Then click on 'Access Control' link on the top and add at least one new user.

Now you are all done with OpenSVN and you really never have to go back unless you are adding new users.

Install the Required Programs on your Machine

There are a few options here, but I prefer to use the tag-team of VisualSVN and TortoiseSVN in combination with Visual Studio, it works flawlessly!

TortoiseSVN is a standalone client that integrates directly with windows and does not neet Visual Studio, you can use this by itself if you want, but I prefer to also add VisualSVN as it ties Tortoise and VS together.

Install Tortoise first (this will require a reboot) then install VisualSVN. Now that is all done... simple.

Putting it all together

Ok, now the last part which is the hardest, and it is still incredibly simple.
  • Open an existing website in Visual Studio and you will see a new menu: 'VisualSVN' click on it and go down to 'Add Solution to Subversion'
  • A popup will come up, check 'I will set working copt root manually' and click 'Next'
  • This is the important part: Make sure that you select the correct folder that your project is in! Then click 'Next'
  • Choose 'Exisiting Repository' and click 'Next'
  • In the 'Destination URL:' box, type in the project location url from above (I prefer to use the https one)
  • It will prompt you for username/password, this is the user that you made up above, then click 'OK'
  • After verification, it will ask you if you want to import your new files (since the repository is empty) click 'Import' - this may take a bit
  • And... your done, everything should be working correctly now - you can use either Visual Studio or Tortoise to keep your project up to date


Finished


And that's it, you are set up to use SVN. There are simple buttons in VS that allow you to commit and update. Commit will push your changes to the repository, while update will pull the most recent copies in the repository to your local directory. Also, you will notice that you will be able to see the file/folder status of the items in your solution in the Solution Explorer (green=current, yellow=needs commit, etc.) -- great integration with VS. Keep in mind that you can also do commits, updates and all other operations in Windows with the Tortoise interface which is built in - just right click on a file or folder and look in the 'TortoiseSVN' menu.

Now that you have SVN working, there is a great free online book all about it: http://svnbook.red-bean.com/en/1.5/svn-book.html.

Other Free SVN Host Providers

Oddly enough, OpenSVN does not dazzle everyone, there are more out there, I just prefer the simplicity it brings. These are all available for free, though you have to pay for upgraded usage:

Shout it kick it on DotNetKicks.com

Related posts

Comments

2/4/2009 7:48:11 AM

Kalyan
great stuff for starters.
Can we integrate SVN with TeamSystem?

Kalyan gb

2/4/2009 12:40:46 PM

Chris Marisic
I host all of my source on Assembla.com, they offer a wide range of hosting for free and open source projects up to corporate level source hosting. Aside from just offering SVN access they also include a wide range of online collaboration tools, a built in SVN code browser, an issue tracker, wiki and your projects can be setup to offer private and/or public access.

I also personally like AnkhSVN for visual studio integration.

Chris Marisic us

2/4/2009 2:22:15 PM

Bert Huijben
"For Free" ?

VisualSVN is not for free, nor open source. (And VisualSVN just wraps TortoiseSVN instead of integrating in Visual Studio as a real SCC provider).

Bert Huijben

2/4/2009 2:43:19 PM

naspinski
@Chris
I am going to try Assembla with my next project, I have heard good things!

@Bert
VisualSVN is free, check out the link... I know it is just a wrapper, but it does the job.

naspinski

2/4/2009 5:46:57 PM

Mårten
"This version of VisualSVN is full featured and includes 30-day trial license." Free as in free trial?

Have you discovered any benefits of using VisualSVN over AnkhSvn? The last versions has been really nice in my opinion, although we're using another vc system at work and it's been a while since I did develop in my spare time.

Mårten se

2/5/2009 4:01:29 AM

naspinski
How did I not notice that it was trial?

I haven't tried AnkhSVN (blocked form work) - I will check it out.

naspinski us

3/5/2009 8:39:35 PM

dotnetguts
Do you have any Subversion configuring stuff for VS.Net 2003 or VB 6.0

dotnetguts us

7/24/2009 6:16:49 PM

Sumit Gupta
Hello,

Thanks for your post it is really helpful. But my question is Can you really rely on these open source Server like openSVN? I mean why they host our commerical source for free?
I am not against open source, but wondering if we can rely on such hosting? Even if I am making a weekend Game or small kid application can I Rely that this or any other open source realy remain there to serve and host my code for atleast 2 yrs?

Sumit Gupta in


Comments are closed