Building a MVC2 Template, Part 2, Version Control

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.

W1

W2

W3

W4
I choose to install the plugins.  You can also select a different language if you desire.

W5

W6

W7

W8
Installing…

W9

W10

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.

1

2
Accept the License Agreement.

3
For this installation VisualSVN will manage the users.

4
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.

5

6
Installing…

7
Sure, start the service.

8
From the Start Menu locate the VisualSVN Program folder and start the VisualSVN Server Manager application.

10
Lets create a new user, so right click on Users and select Create User.

11
Enter a username and password.

12
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.

Tortoise1

Tortoise2
Accept the License Agreement.

Tortoise3
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.

Tortoise4

Tortoise5
Installing…

Tortoise6

Tortoise7
You will need to reboot for the changes to take affect. You should definitely reboot here.

Tortoise8
After the reboot open Windows Explorer. Right click on any folder to get the context menu.  Select TortoiseSVN and then Settings.

Tortoise9
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.

Tortoise10
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

Tortoise11
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.

Ankh1

Accept the License Agreement.

Ankh2

Installing…

Ankh3

Finished!

Ankh5

Reboot one more time!

VS1
After your computer reboots, start Visual Studio. From the menus select Tools followed by Options.

VS2
Open the Source Control item in the options tree on the left.  Select the Ankh plugin.

VS3
For the Subversion Environment options I left all these items unchecked.

VS4
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.

Nehemiah1

So fire up VisualSVN and we’ll create a new repository named DemoProjects.

Nehemiah2
For the repository I don’t need to include a trunk, branches, or tags folders.

Nehemiah3
Our repository has been created!

Nehemiah4
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.

Nehemiah5
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.

Nehemiah6
Now that our project has been created lets compile and run the application.

Nehemiah7
Yes, we want to enable debugging.

Nehemiah8
It runs in Internet Explorer!

Nehemiah9
and FireFox!

Nehemiah10
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.

Nehemiah11
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.

Nehemiah12
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.

Nehemiah13
Open the Pending Changes pane in Visual Studio. Then click Commit.

Nehemiah14
Our files are being added to Subversion.

Nehemiah15
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.

Shout it


Kick It on DotNetKicks.com
Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Shout it
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter
Google Buzz (aka. Google Reader)

Leave a Reply

Comment moderation is enabled. Your comment may take some time to appear.