SVN, Hudson and MSBuild - Revision control repository

SVN, Hudson and MSBuild - Continuous Integration
SVN, Hudson and MSBuild - Building code on post commit

This three part series of posts I’m starting today serves as a guide on how to setup a continuous integration/CI server.

Tools I’m going to use (all FREE) and a brief description of them:

Continuous integration

Hudson Hudson

Hudson monitors executions of repeated jobs, such as building a software project or jobs. Hudson helps building/testing software projects continuously. In a nutshell, Hudson provides an easy-to-use so-called continuous integration system, making it easier for developers to integrate changes to the project, and making it easier for users to obtain a fresh build. The automated, continuous build increases the productivity.


Build automation

MSBuild (Visual Studio 2010 native build system)

The Microsoft Build Engine (MSBuild) is the build platform for Microsoft and Visual Studio. MSBuild is completely transparent with regards to how it processes and builds software, enabling developers to orchestrate and build products in build lab environments where Visual Studio is not installed.


Revision control

TortoiseSVN

TortoiseSVN is an easy-to-use SCM / source control software for Microsoft Windows and possibly the best standalone Apache™ Subversion® client there is. It is implemented as a Windows shell extension, which makes it integrate seamlessly into the Windows explorer. Since it's not an integration for a specific IDE you can use it with whatever development tools you like.

VisualSVN Server

VisualSVN Server allows you to easily install and manage a fully-functional Subversion server on the Windows platform. Thanks to its robustness, unbeatable usability and unique enterprise-grade features, VisualSVN Server is affordable both for small business and corporate users. It greatly simplifies installing and managing Subversion and is available for free.

The series will focus on continuous integration of .NET family of projects and I’ll write things in the order I installed them.

This 1st part will deal with the Revision Control repository configuration.

The only difference here is that I’m running all these software engineering tools on my Windows 7 virtual machine that is used exclusively for software development. A more ubiquitous situation is when/where you have each one of these tools working on their specific servers, that is, you’ll frequently see a dedicated continuous integration server, a dedicated build server and a dedicated repository server.

Having dedicated servers is good for a software development team/company. This definitely isn’t my case. I’m doing solo work and as such I decided to have a stable environment which can give me all the benefits of a continuous integration process running in a single machine (cost effective solution). This allows me to apply a better quality control over my code and at the same time I can automate common tasks.

These tools are working great on my machine right now where I’m developing and integrating an ASP.NET MVC 3 application. Bellow I’ll describe what you need in order to get a revision control repository running in your development machine.

I try to simplify every step going to the point and avoiding the intrinsic aspects such as why things are named or done this or that way.

When you finish this step by step guide, the following question should be answered:

Question: How/Why should I put my code under revision control?

Valid answer:

1 - Download and install TortoiseSVN. TortoiseSVN is a Subversion client.

2 - Create the SVN folder for your project. For example in C:\svn\MyProject. Right-click this folder and select TortoiseSVN → Create repository here. You should get a confirmation message like this one:

TortoiseSVN - Repository Successfully CreatedFigure 1 - Repository Successfully Created

3 - Create this temporary folder structure so that you have a standard SVN folder layout:

C:\Temp\MyProject\trunk
C:\Temp\MyProject\branches
C:\Temp\MyProject\tags

Do not mind the Temp folder for now. The main idea here is that you’ll put you current project’s folders/files inside the trunk folder. For more on this, read revision control.

4 - Move all MyProjects’s code to the trunk folder.

5 - Now right click the folder C:\Temp\MyProject and select TortoiseSVN → Import… Now you must provide the SVN address where you want to import your project. Do this:

TortoiseSVN - ImportFigure 2 - Import

Note the slashes ( / ) instead of back slashes ( \ ).

Before you import the project into the repository take note of:

- Just import the content needed to build the project. Remove unnecessary or temporary files/folders generated by the compiler e.g. Files = *.suo/*.user and folders = Bin/obj that contain compiled binaries.
- Organize your project in folders and subfolders. Using TortoiseSVN you can later rename/move files but it’s highly recommended that you set your project’s structure before importing!

After clicking OK, you should see this:

TortoiseSVN - MyProject Import FinishedFigure 3 - MyProject Import Finished

Great. Now we have just imported MyProject’s files to a revision control repository. See that we are at revision 1.

Now we’re going to check out this code in a different folder so that we can have the benefits of revision control.

6 - Create the folder C:\MyProject.

7 - Right click C:\MyProject and select SVN Checkout…

TortoiseSVN - CheckoutFigure 4 - Checkout

After clicking OK, you should get this:

TortoiseSVN Checkout FinishedFigure 5 - Checkout Finished

You’ll see that Windows Explorer now shows an icon in each file/folder informing that that specific file/folder is up to date or not with the one we have in the SVN repository:

Windows Explorer with Project Under Version ControlFigure 6 - Windows Explorer with Project Under Version Control

As you can see, I have changed the content of the file Main line Project Files and Folders go here.txt and as a result of this action I’m informed that this file was changed since the last check out (red exclamation mark). When I perform a commit to the repository this file that is marked as modified will be part of the head revision of the repository.

TortoiseSVN context menu options
SVN is a really powerful tool that has a lot of functions as the revision graph selected bellow:

TortoiseSVN - Context Menu OptionsFigure 7 - TortoiseSVN Context Menu Options

You’ll learn about and use each one of these functions for sure as the time passes by. Do not panic and take it easy! Surprised smile Be careful though when performing a commit to the repository and avoid breaking things. This can cause headaches.

Summary
In this simple step by step guide you saw how to put a project under revision control. This gives you a cool way of keeping track of what has been added, deleted, changed in your project since its start through what we call revisions. In addition you also get the chance of rolling back your changes in case anything goes wrong. This I think is the greatest feature of a revision control repository, that is, it acts in such a way that if I later decide to rollback to a previous version of a given file I’m allowed to do so because it keeps the old files. This works just like the database rollback function.

Next in this series
In the 2nd part of this series I’ll go into the details related to the installation and configuration of Hudson that is the continuous integration server.

More MP3 guessing pattern with Mp3tag in Mac OS

I mentioned in my last MP3 series post that I had the material to write a new post regarding this topic and so today I’m fulfilling the promise I made. I’m going to show how you can use the powerful Swiss Army knife called Mp3tag (Windows “only” app) right within your Mac. Yes, you read it right. You can run Mp3tag using your Mac. Nowadays almost everything is possible… Open-mouthed smile

The great thing here is that there’s a way to use our beloved Mp3tag in Mac OS. I even asked a question at SuperUser where I was trying to find some similar software that I could use in Mac. Here’s the question: Alternative to mp3tag for Mac OS X. Well, after searching a little bit more I found a great site called PlayOnMac. What is PlayOnMac?

PlayOnMac is like wineskin, winebottler or crossover a piece of software which allows you to easily install and use in your Mac numerous games and software designed to run only with Microsoft®'s Windows®.

I then found Mp3tag bundle here. You get a .dmg file which contains Mp3 Tag.app (172.5 MB) on disk. Just mount the .dmg file with a double click and extract the .app file to your Applications folder in Mac OS dock. Doing this you have the power of Mp3tag right inside your Mac. No Windows virtual machine needed/no need to load your bootcamp Windows. It’s good because you’ll have more memory left for your Mac (in the case of a virtual machine) or you won’t spend your time changing the operating system (in the bootcamp case).

Ok, the bundle is a little bit lazy to load and the visual (retro) is Windows like but who mind?

There’s nothing better than a use case to showcase something. Today I need to organize some MP3 tags because their Track - Artist - Title fields are all a complete mess. Some data are already there and some are missing completely. I of course will use Mp3tag guessing pattern feature to solve this.

To get to the Guess values dialog window, click the Actions (Quick) icon in the toolbar and select Guess values in the dropdown menu. Screenshots can be seen here.

Here are the MP3 files before the process:

Mp3tag Guess Values for Track Artist and Title in FileName [ before ]Figure 1 - Mp3tag Guess Values Window for Track Artist and Title in File Name [ before ]

As you see most of the tracks have 1 in the Track field and Title and Artist fields are missing in most of cases. All the information that is missing is present in the Filename field. Really interesting fact.

Let’s take advantage of Filename info and fill the missing tags with that data. How? Using Mp3tag Guess values window.

Source format: %_filename%

Guessing pattern: %track% - %artist% - %title%

Really easy, isn’t it?

What the hell these % symbols are doing here? They are simple placeholders that tell Mp3tag about a specific pattern found in fields of MP3 files. In this specific case, Mp3tag will extract data from the Filename field ( source ). Looking at Figure 1 we see that all file names follow a pattern: Track # - Artist - Title. Such pattern is then passed to Mp3tag in the Guessing pattern field. With this input Mp3tag is able to infer/parse the file names and split them accordingly. Each part will then be used to fill the correct MP3 tags.

Here’s the post-processed MP3 files:

Mp3tag Guess Values Window for Track Artist and Title in File Name [ after ] Figure 2 - Mp3tag Guess Values Window for Track Artist and Title in File Name [ after ]

That’s a much better view and experience within your preferred Media Library software!

Things like this makes me really happy with computers…

Hope you find it as useful as it’s being to me in this hard task of keeping a MP3 collection organized. I at least try my best.

To see more ways of using the Guessing Pattern, check the MP3 series of posts.

Access web app from Parallels Win 7 VM in Mac OS

About a month ago I started the creation of an ASP.NET MVC 3 app to a buddy. I’ll write some blog posts in the near future sharing my experiences with this awesome web framework. This app I’m still developing is a web application that I develop using my "new” computer. Today I use Mac OS as my main operating system and since I’m using ASP.NET I also need to use Windows.

Parallels Desktop is the way to go to have a Windows virtual machine [ VM ] running side by side with Mac OS. This way you have the best of both worlds. I discuss more about Parallels Desktop here.

One of the things I wanted to do during the development was seeing how the app would look like when viewed in a different OS, in this case, I’d like to see it running in Mac OS as if I were an end user accessing the app. This is good to test how the app behaves when it’s viewed in a different environment, that is, the perspective/environment of the end user, and not the developer’s perspective/development environment.

It’s cool to see the app running in a different OS and different web browsers. In Mac OS I have the chance of testing it against Safari too. I also have the chance of seeing how exceptions are being handled. There are certain types of errors that only happen when the end user is using the app in his environment. I think you know that already. This kind of testing allows me to deliver a better user experience.

When the app is accessed from the Mac side, the first difference is mainly visual because my Win 7 VM has all visual effects (clear type) disabled and so things look really simple if compared to Mac OS. I’m running the VM with no visual effects so that I have a somewhat fast VM to do the development. I only have 4 GB RAM available and I have to share it with both operating systems. I thought 4 GB RAM would suffice but that’s not the case. I have already ordered 8 GB RAM but am eagerly waiting it arrive from US. That’s another story that I plan to write in other blog post.

The reason I’m writing this post is that things don’t work at first when you try to access in Mac your app that is running in Windows VM. To get things working from both sides ( host = Mac OS and VM = Windows 7 ) they must see/communicate with each other. That’s where I had to do some work to get things going. So here are some instructions of what you need do:

1 - Set a fixed IP address for Windows VM
Set up a fixed IP address (read this page for a complete guide) in your Windows 7 virtual machine. This will make it easy when you need to access your app from Mac OS side. You won’t need to take note of different IP addresses handled by the DHCP server each time you restart your VM.

Windows 7 VM with fixed IP addressFigure 1 - Windows7 VM with fixed IP address

Above I have given the IP 192.168.1.106 to the VM. As I do not have a lot of devices connected to my wireless router, this IP is just fine.

2 - Set Virtual Machine’s Network Type
In your Parallels VM devices bar set your network type (orange arrow) as bridged:

Parallels Desktop VM devices toolbarFigure 2 - Parallels Desktop VM devices toolbar

3 - Test Communication between Host and VM
Make sure both operating systems can see each other.

Open Mac OS Terminal and execute a ping command:

ping 192.168.1.106

Change the IP with the IP you have in your Windows VM.

You should see something like this:

Mac OS Terminal pinging Windows 7 VMFigure 3 - Mac OS Terminal pinging Windows 7 VM

Now, open Windows 7 Command Prompt and ping Mac IP address. To see your Mac IP address go to System Preferences. Under Internet & Wireless, select Network.

Mac OS IP addressFigure 4 - Mac OS IP address

Let’s ping 192.168.1.100:

Windows 7 VM Command Prompt pinging MacFigure 5 - Windows 7 VM Command Prompt pinging Mac

As you see, both computers can see/communicate with each other. This means that the Network is working as expected.

4 - Configure Windows VM webserver for external traffic
What address should you type in a Mac OS browser to access the app? Well, this needs a little bit of caring. You’ll probably fail when trying to access the app with the same address you use in Windows side.

I’m using IIS Express as the web server in Windows. You can install it using Microsoft WebMatrix. IIS Express is by default configured to only server internal traffic (Windows VM). As I’m trying to access it from an external environment (Mac OS), I needed to configure it. The first link bellow was the main doc that helped me:

Serving external traffic with WebMatrix Beta
Handling URL Binding Failures in IIS Express (Serving External Traffic)

Basically I had to configure HTTP.SYS, create a URL binding that allow me to access the app in Mac side and disable Windows Firewall for my private home network.

4.1 - Configure HTTP.SYS
Type this command in Windows command prompt:

netsh http add urlacl url=http://leniel-pc:7777/ user=everyone

Change the url in the above command according to your desired configuration.

Note: the above command requires elevation. Right click the command prompt shortcut and select Run as administrator.

4.2 - Configure URL binding
As mentioned in the 2nd doc referenced above you must open your applicationhost.config file and add URL bindings that fit your needs. Mine is located here:

C:\Users\Leniel\Documents\IISExpress\config\applicationhost.config

Take a look at the last binding I have added:

<site name="FitnessCenter" id="3">

<application path="/" applicationPool="Clr4IntegratedAppPool">

<virtualDirectory path="/" physicalPath="C:\Users\Leniel\Documents\Visual Studio 2010\Projects\FitnessCenter\FitnessCenter.Web" />

</application>

<bindings>

<binding protocol="http" bindingInformation="*:7777:leniel-pc" />
<binding protocol="http" bindingInformation="*:7777:localhost" />

<binding protocol="http" bindingInformation=":7777:leniel-pc" />

<binding protocol="http" bindingInformation="192.168.1.106:7777:"/>

</bindings>

</site>

4.3 - Configure Windows VM firewall
The last step is disabling Windows VM firewall for your Home or work private networks.

Windows 7 VM FirewallFigure 6 - Windows 7 VM Firewall

As I just use this virtual machine to do software development, it’s ok to me to disable the firewall. Be careful though. Surprised smile

5 - Access Win 7 VM web app in Mac OS
After all this configuration you should be able to browse your app externally.

To see if everything is working, open a browser in Mac OS and try to access the app typing something as this in my case:

http://192.168.1.106:7777/

That’s it.

Hope it helps.