Building a MVC2 Template, Part 2, Version Control
Mar 29
.Net, Development AnkhSVN, Asp.Net Mvc, Nehemiah Project, Subversion, TortoiseSVN, VisualSVN, WinMerge No Comments
In this posting we will cover the steps necessary to install Subversion along with support applications and then add our project to source control.
There are numerous posts on the internet for installing Subversion and its usage. I know they have helped me get everything configured and installed. If I could remember them all I would reference them in the article, but alas, I cannot remember. Also, I don’t remember any that tied all of these steps together. If they did or do exist, I did not stumble across them.
There are several choices for version control available today. Among these are Subversion, Git, and Mercurial. For this project I will be using Subversion and we’ll download these applications:
- WinMerge – An open source differencing and merging tool for Windows
- VisualSVN – Subversion management
- TortoiseSVN – Windows Explorer plugin
- AnkhSVN – Visual Studio plugin
The installation of these items may require up to three reboots of your computer. Just warning ya!
There are a ton of images in this post.
NOTE: If you don’t have Asp.Net MVC 2 installed, you’ll need to download it from here http://www.microsoft.com/web/gallery/install.aspx?appsxml=http://www.microsoft.com/web/webpi/2.0/WebProductList.xml&appid=MVC2. When I wrote this I made the assumption you would have had this already installed.
Installing WinMerge
At the time of this article the version is 2.12.4. Download and install. I kept all the defaults, except on the Select Components screen, I elected to install the plugins.
![]()
I choose to install the plugins. You can also select a different language if you desire.
The install will want to reboot your computer. Make sure you select No if you don’t want to reboot at this time.
Installing VisualSVN
At the time of this writing the version number for VisualSVN is 2.1.1. So lets download the latest version and install it.
![]()
For this installation VisualSVN will manage the users.
![]()
Since VisualSVN will install Apache and I do not want it conflict with IIS, VisualSVN will be setup to use port 81. If you choose there is a way to add Subversion to an existing Apache installation. I will leave that exercise for a later installment.
![]()
From the Start Menu locate the VisualSVN Program folder and start the VisualSVN Server Manager application.
![]()
Lets create a new user, so right click on Users and select Create User.
![]()
Enter a username and password.
![]()
Viola! Our user has been created. You can add more users if needed. I just need the one user for now. We’ll add more as required.
Installing TortoiseSVN
Download the installation msi file if you haven’t already done so. At the time of this article the version is 1.6.7.
![]()
I only need one version of English, so I elected to not install the Queen’s English. For my cousins across the pond and around the world, you shouldn’t need the Americanicized (see how I/we did that) English version. Its all good.
![]()
You will need to reboot for the changes to take affect. You should definitely reboot here.
![]()
After the reboot open Windows Explorer. Right click on any folder to get the context menu. Select TortoiseSVN and then Settings.
![]()
I made just a couple of changes to the defaults. First I changed the Global ignore pattern to the string below. I don’t remember exactly where I picked up some of these file extensions. You can modify as needed.
*.o *.lo *.la *.al .libs *.so *.so.[0-9]* *.a *.pyc *.pyo *.rej *~ #*# .#* .*.swp *.obj thumbs.db .DS_Store
Second I changed the svn folder name from .svn to _svn. Which one you use is simply a matter of personal preference. Newer versions of Windows should not have any issue with folders whose name consists solely of an extension.
![]()
Next click on the Diff Viewer item in the options tree on the left side of the dialog box. Set both viewers to External with this string:
C:\Program Files\WinMerge\WinMergeU.exe -e -x -ub -dl %bname -dr %yname %base %mine
![]()
For the Merge Tool you can use either the internal TortoiseMerge or define an external merge tool such as WinMerge. I selected External and used the following for the command line.
C:\Program Files\WinMerge\WinMergeU.exe
Click OK to save your changes.
Installing AnkhSVN
Download the installation msi file if you haven’t already done so. At the time of this article the version is 2.1.7819. Make sure you have no copies of Visual Studio running during this install.
Accept the License Agreement.
Installing…
Finished!
Reboot one more time!
![]()
After your computer reboots, start Visual Studio. From the menus select Tools followed by Options.
![]()
Open the Source Control item in the options tree on the left. Select the Ankh plugin.
![]()
For the Subversion Environment options I left all these items unchecked.
![]()
Under the Subversion User Tools I changed the External Diff Tool to WinMerge. The External Merge Tool was changed to WinMerge (2-Way). The External Patch Tool was set to TortoiseSVN TortoiseMerge, even though for Tortoise I set the patch tool to WinMerge.
Click OK to save your changes.
Creating Our Asp.Net Mvc2 Application
Before we create our application we need to create a repository in Subversion to hold our source code.
So fire up VisualSVN and we’ll create a new repository named DemoProjects.
![]()
For the repository I don’t need to include a trunk, branches, or tags folders.
![]()
Our repository has been created!
![]()
Now we can create our application. Create a new Project and select a project type of ASP.NET MVC2 Web Application.
Since this will be a new reusable framework built on top of Asp.Net Mvc2, I’ve decided to name the project Nehemiah. Nehemiah was responsible for rebuilding Jerusalem when Judah was a province of the Persian Empire. Feel free to use a different project name.
You can elect to automatically add the project to Subversion by check the Add to Subversion checkbox if you choose. I will do it manually to show the steps involved.
![]()
Lets go ahead and add a Test project. Name it Nehemiah.Specs, even though the two screen shots have Nehemiah.Tests. We’ll modify it in a later installment.
![]()
Now that our project has been created lets compile and run the application.
![]()
Yes, we want to enable debugging.
![]()
From the File menu select Subversion, then Add Solution to Subversion. You will be asked to log into the Subversion repository. Use the username and password you created above. Sorry no screen shot for the login.
![]()
Enter the name of your repository. It will be something like this http://mysvnserver:81/svn/DemoProjects/. When we installed VisualSVN we configured the server to use port 81 and DemoProjects is the name of the repository. Replace mysvnserver with the name of the computer hosting your Subversion repository.
Make sure you check the checkbox labeled Add trunk Folder. Then click OK.
![]()
Add a comment for the initial auto generated source code. Our solution is now linked to our Subversion repository, but our code has not been committed (or checked in for Source Safe users) yet.
![]()
Open the Pending Changes pane in Visual Studio. Then click Commit.
![]()
Our files are being added to Subversion.
![]()
Using VisualSVN to check our repository shows the files have been added to Subversion.
Congratulations! You now have setup a Subversion repository and added your first application to source control.
Our next installment we’ll setup TeamCity do do automated builds.













Recent Comments