2007-04-27

Delphi 2007 in a RADical build - Part 1

Sinopsis: In this multi-part tutorial, I'll explain how you can setup your development environment on a VM, complete with version control (SVN), and continuous build integration.

This is mostly as it relates to one-man-shops, but it can be used for other small shops as well. Don't forget that, for multi-man shops you will require additional licenses for the OS, Delphi and any 3rd Party Components...

What will you gain from all this?

1) Setting up your Dev environment in a VM will allow you to grab another computer, install a VM Player, copy the VM files from some DVDs or external drives and be ready to rock in minutes, should you have some major problem on your main machine;

2) Using a VM ensures you always have a clean but fully configured machine and that it stays clean and fully configured;

3) Using SVN will overall improve your work by allowing you to compare changes, check certain builds/releases for bugs, fix urgent bugs in the release that is currently shipping without having to rush out your current untested and unfinished release;

4) Using continuous build will help you improve the overall quality: no-one likes to see a red icon around pointing you a finger saying "you broke this!", so you'll try harder to commit fully working builds to the repository;

5) Not only that, but should you work on multiple inter-related projects, you'll quickly find out if you broke something on another project and thus it will be much easier and faster to fix that while you still remember what changes you made...

6) Overall, you'll be able to resume working faster should anything serious happen, you'll be able to keep a fully working/clean environment, and you'll catch and fix bugs faster.

This article is divided into 4 parts:

Part 1: Setting up your VM and OS.
Part 2: Configuring the OS to start faster and use less memory/CPU.
Part 3: Setting up Delphi 2007, Subversion, Tortoise SVN, CruiseControl.NET.
Part 4: Tips and tricks on using Subversion.

Part 1 - Setting up your VM.

You will require the following items:

1) VMWare Workstation (if you use something else, just adapt accordingly)
2) Windows Small Business Server 2003 R2.

Why not Windows XP or Windows Vista?
Well, you can get WinSBS 2003 for roughly the same amount as a new (non-OEM) license for Vista and/or XP and Windows 2003 Server will add less clutter to your Virtual Machine, require less disk space, and will overall run faster, especially after some tweaking as we will do in Part 2... You can however use other versions of Windows if you want: just ignore/adapt where needed.

1) Setup VMWare Workstation if not already done. I prefer not to let it disable CD/DVD auto-run, because I rarely use physical CD/DVD drives in the VMs: I prefer to use ISO images.

2) If you have the disk space, even if on an external drive, create the ISOs for the SBS CDs. I use UltraISO for that, but feel free to use any other util of your choice. You will only need Disk 1.

3) Create a new custom Virtual Machine and, for the OS, select "Windows Server 2003 Standard Edition". Standard is just fine since we won't be using much of the SBS software anyway.

1) Give it as much RAM as you can without exceeding the Maximum recommended memory. It will be great if you have at least 2 GB of RAM on your physical machine, but don't despair: you can get it working with 1 GB or even less, if you don't run many simultaneous programs other than the VM.

2) You can use NAT for the network, unless you need to have this VM accessible from some other computer. In that case, I'd recommend the default Bridged connection and preferably a fixed IP outside of your router's DHCP range, if you use one.

3) Create a new Virtual Disk (you can use physical disks but then this VM will not be easily portable and you'll loose much of the flexibility in setting up a VM with your Development environment!).

4) The 8 GB default is just fine for Windows + Delphi + quite a few 3rd party tools + Subversion + CruiseControl, but you can safely use more if you have the space. You can also at any time expand that disk if you need more space, but it's faster to plan ahead and choose a proper value before starting.

5) For performance, you may want to select the option to "Allocate all disk space now": this way the disk files won't be growing on the go and it will run faster. You *will* want to check the "Split disk into 2 GB files" option: that will make backing up into multiple DVDs a lot easier, plus it will allow you to store the VM on a FAT disk drive, be that external or not, should it be needed.

6) When the disk is created (it will take a couple minutes reserving all that space), double click the CD-ROM device on your new VM and choose either the ISO created in step 2 or the physical drive containing the 1st WinSBS CD.

3) Start your VM and install Windows SBS.

4) Install IIS: if it's already installed when setting up .NET, it will be configured for ASP.NET; otherwise you'll have more work later;

5) After starting up the VM with the freshly started OS, install VMWare Tools.

6) Activate your OS.

7) Run Windows Update and install all *critical* updates: you don't need IE7 on the VM and you can disable it being pushed onto your computer by using this tool from MSFT: http://www.microsoft.com/downloads/details.aspx?FamilyId=4516A6F7-5D44-482B-9DBD-869B4A90159C&displaylang=en

Time to catch some sleep now...
Stay tuned for parts 2-4...

6 comments:

iSkomorokh said...

Thanks for the good topic! This theme is very crucial nowadays. Looking forward to see some advanced usage of SVN.
And now one question: How to create Virtual disk and why this way is preferable.

--
http://delphigeek.blogspot.com

Thomas Mueller said...

Hi,

interesting that I am no the only one preferring Win 2003 for a development VM.

I am looking forward to your next installments, especially the one on continous integration since that is something I haven't set up myself yet.

regads
twm

iSkomorokh said...

It is also worth to check http://www.stevetrefethen.com/blog/
Steven highlights this theme too.

Fernando Madruga said...

iSkomorokh: Creating a Virtual Disk is an option you're given when creating a new VMWare disk or as part of the VM creation.

You can use a Physical Disk, but in that way you're "locking" the VM to that particular machine. Or, before using the VM elsewhere, you need to use a partition cloning utility to "save" that partition and recreate it on the new host machine, which is just too troublesome to be worth it.

Using Virtual Disks, you're in fact creating a whole Disk inside a file, or, inside a few 2 GB files. All you need to get up and running on another machine is to backup that whole VM directory including those 2 GB files. Then simply install the player on a new host and copy those files to any directory of your choice and launch the VM.

Performance, in VMWare, does not suffer noticeably from using Virtual Disks and you gain a lot in flexibility.

As for Steve Trefethen's Blog, it's where I got my inspiration for the continuous build setting! (Properly credited for it on the suitable part of this article!)

iSkomorokh said...

Thanks for the great explanation about Virtual Disks!

Joe White said...

Awesome series idea. We already have continuous build set up at work, but I haven't set it up at home -- so I look forward to parts 2 through 4. Thanks!