Assert.That(this, Is.Easy); Coding Tunes
Feb 16

This past week I setup a new development environment on my MacBook Pro. As I got into it, I realized that it might be a good idea to share the setup process with others who might be switching to a Mac. Unlike a lot of people that use Windows XP for development, I do all my .NET development on Windows Server 2003. I have always had a firm belief in developing on your target environment.

For this discussion, I will be using VMware Fusion to run Windows. I’ve always been a fan of VMware, and their Mac OS X version continues to impress. There are many slick features in VMware Fusion, including Unity mode and dual-processor support. I’m going to be installing on my MacBook Pro, which is a 2.4 GHz Core 2 Duo with 4 GB of RAM (using the Santa Rosa platform, for full 64-bit memory support). I’m going to install the 32-bit version of Windows Server 2003 since the tools are all 32-bit applications.

I highly recommend getting your installation disks as ISO files (from MSDN, of course). VMware can mount the disk images directly, and they load a lot faster than using the physical media. For the purpose of this installation, you’ll need the following disk images:

  • Windows 2003 Server R2 with Service Pack 2 (disk 1, 2 is not needed)
  • Visual Studio 2005 Professional
  • Microsoft MSDN Library for Visual Studio 2005 (optional)
  • Microsoft SQL Server 2005 Developer Edition

You’ll also need the following downloads:

Creating the Virtual Machine

To create your virtual machine, start up VMware. On the Virtual Machine Library window, select New. On the New Virtual Machine Assistant, click Continue. For Operating System, choose Microsoft Windows, for version, choose Windows Server 2003 Standard Edition. When choosing a name for your VM, I find it helps to pick something that reflects what development will be done. I have two, one called W2K3×2K5 and one called W2K3×2K8. As you might guess, the first has Visual Studio 2005 and the latter has Visual Studio 2008.

When choosing a disk size, be sure to give yourself enough room for your tools and applications, but don’t go overboard. Before I rebuilt my VMs, none of them were over 14GB in size so I chose a size that would give a little room to grow. Now, you could pick something like 40GB and configure the VM to grow the disk file as space is consumed but I prefer to allocate the entire disk in 2GB chunks at creation to get the best performance. I don’t usually use a lot of local space since all of my source code is kept in a remote Subversion repository.

The next screen is the Windows Easy Install. This is an easy way to get the operating system setup without any user intervention. Just make sure your install disk ISO is ready, and enter your name, password, and Windows key. Check the “Make your home folder accessible to the virtual machine” so that you can easily transfer data from OS X to Windows. I make the folder read only, since I don’t trust Windows to write to my home folder. Once the Finish screen displays, uncheck the Start and Install now option since we want to make some tweaks before the OS install begins. You can go ahead and pick your ISO for the installation.

Once the VM has been created, go back to the Virtual Machine Library, pick your virtual machine, and click Settings. We need to tweak a few things before we let Windows install.

  • Battery - I let the guest see the battery status
  • Display - Uncheck since we are not using XP
  • Memory - I give the VM 1492 MB, but you can adjust to taste.
  • Processors - Two (2) virtual processors should be set for installation.
  • Network - NAT or Bridged are the only real options here. NAT is good when you don’t need other machines to have access to the VM, but use Bridged if you want a direct link to the network. If you use NAT, you can get to your Mac from the VM using the .host name.
  • Sound - I like sound, I enable it.
  • Shared Folders - This should be fine based on how the VM was created.
  • USB - I like to be able to use my flash drive in the VM, so I enable this option.

Once the settings are tweaked, go ahead and fire up the VM. Windows should install without any user intervention and after a short time (the install runs super fast from the ISO) you should have a working Windows Server 2003 installation. Once you have it up and you are logged in, it’s time to run Windows Update to get all the latest patches (there will be a ton of them). Go ahead and let them install, and be sure to get the optional .NET 2.0 and .NET 3.0 packages as well.

Now that we have Windows setup, it’s time to take away all the things we don’t need.

  • Disable automatic updates — we can do that when we need to do it.
  • Disable remote access into the machine (no Remote Desktop or Remote Assistance).
  • My Computer, Properties, Advanced, select Adjust for Best Performance for Memory and CPU.
  • Set virtual memory to a fixed size of 1GB.
  • Advanced Startup and Recovery - Uncheck all reporting and set Debugging Information to none.
  • Disable error reporting and turn off critical error notification

In the control panel, we need to tweak a few things as well:

  • Set your time zone and turn off automatic time synchronization.
  • Turn off the screen saver, set the background to none, and make sure Windows Classic is selected for the theme.

In the registry, this tweak really decreases disk access in your VM:

  • HKLM\System\CurrentControlSet\Control\FileSystem
    Add a new DWORD named NtfsDisableLastAccessUpdate and set it to 1.

I also disable the following services:

  • Automatic Updates
  • Error Reporting Service
  • Help and Support
  • Windows Time
  • Wireless Configuration

Remove the following files:

  • All the $whatever$ directories in C:\Windows except for the $hf_mig$ directory.

Add Operating System Components

  • Use Add/Remove Programs, and select the Add/Remove Windows Components option.
  • Add IIS (including ASP.NET support)
  • Add Message Queueing (if you plan to use it)
  • Remove Enhanced Internet Explorer Security
  • Install any extra fonts you use for development, such a Consolas.

It’s probably a good idea to run Windows Update again after adding these features since they’ve likely been patched.

Back Up Your New VM

Now that we have a nice clean system, I recommend you shut down the VM and make a backup copy. Simple copy the Documents/Virtual Machines/YourVMName to an external drive so you can easily create new VMs without doing the Windows install again. If you do so, I recommend using SysPrep to reseal the operating system so all new SIDs are created. Do not make a backup for the purpose of closing after installing SQL Server 2005 since it goes crazy if you change the machine name after it is installed.

Software Installation

I recommend installing Visual Studio 2005, followed by SQL Server 2005. For Visual Studio, if you aren’t going to do any Smart Device programming, I highly recommend you uncheck all those packages from the installer. I would also choose not to install Visual J# for obvious reasons. Once the install is complete, be sure to run it at least once. Then install SQL Server 2005 (running as Local System when asked). If you don’t care about SQL 2000 support, don’t bother with the compatibility sort orders and just pick Latin from the top. Once both are installed, go ahead and install VS2005 Service Pack 1 and SQL Server 2005 Service Pack 2.

At this point, you have a pretty basic system with the needed applications. If you’re going to do any work on open source projects, you will need Subversion, TortoiseSVN, and NAnt. Many recommend VisualSVN, but I have never used it so I can’t comment but I’ve heard good things. When downloading applications to install, I recommend pulling them down using Safari into your Downloads folder. Then in your VM, go to the “on my Mac” share and run the installers from your shared folder. I never download anything inside the VM unless I absolutely know it can be trusted (which is pretty much never).

You will notice that I didn’t install any “fearware” such as virus or spyware tools. That’s my style, I don’t really care to slow down my system with things of that nature. I maintain a tight VM and rarely introduce anything from the outside so it’s my choice. Your mileage may vary.

And before I write another word, you should install Resharper and start on your path to becoming a Resharper Jedi.

Wrap Up

I hope this post has been helpful for those looking to setup a development VM. I’ve found that using Leopard OS X for everything but development to be a pleasure compared to the applications available for Windows.

9 Responses to “Developing for Windows on Mac OS X”

  1. Ivan Says:

    Great article!

    I’m going to buy MacBook Pro and I need to use .NET dev tools for work (including Visual Studio and SQL Server 2K and 2005) so I was so curious how it would perform.

    So, how does it perform? Do you find it somewhat slow? Did you have some troubles with software (sql, VS)??

    Thanks for this artice, it’s really useful to me.

  2. Chris Says:

    Well, I have 4GB of RAM and I give about 1.5 GB of that memory to the VM running Windows 2003. I also enable both cores for virtualization. I find performance to be plenty fast doing pretty much anything in Visual Studio 2005. Most of the time Activity Monitor (on OS X) barely shows any CPU utilization except when I’m doing a big compile of all projects.

    And this is with usually a couple of Safari windows, a Skype VOIP call going, and sometimes a Yugma screen sharing session going as well. It just cruises along without really noticing anything like a slowdown.

  3. Ivan Says:

    Thanks for the prompt reply, I’ll surely give it a go as soon as I find new MacBook Pros in my local Apple store.

    Thanks again!

  4. Jon Says:

    I have a very, very similar setup. I know a lot of .NET developers, in fact, who are using Macs as their primary dev machines. Have you tried doing any Cocoa work using Mono yet?

    I also regard antivirus software as a waste of system resources, but one tool that I find very useful in this setup is Little Snitch. As long as your VM is using NAT for network access, Little Snitch will let you approve or deny outgoing connections from your VM on a per-destination basis.

  5. calcif3r Says:

    Hi there!

    Recently I’ve started to adventure in the world of virtual machines on my iMac 24′. But there are two things that I would like to ask:

    When you’re creating a VM, during the setup, do you choose allocate all disk space or do you leave that option unchecked?
    Secondly, I’ve already choosed the “split in 2gb files” option, but seems not to work. :(

    Could you give me a hand? Thanks! :)
    By the way, nice blog!

  6. Dave Says:

    I just bought a MacBookPro a few weeks ago and am running a similar setup to yours. I am a BI/EDW consultant, so I am concentrating more on SQL Server/Analysis Services, but with 2gigs allocated and only 1 core for the VM it screams. I have had no performance issues. Using TimeMachine also and had the VM die on me today but was able to drop back to Monday with no problems.

    One thing I can’t do is get any sound from the WinServer. Do you have any particular drivers you use on the Windows side? I know it isn’t VMWare because I have an XP VM and that works fine.

    BTW, the looks I get from other consultants and business people in my field are hilarious! I usually hear - “oh, you’re a Mac guy” with the inevitable roll of the eyes.

  7. Dave Says:

    I just spent a minute and got the sound to work. Needed to update the driver on the Windows machine. Now it works.

  8. Chris Says:

    Sounds like you have it nailed. I need to review the new stuff in Fusion 2.0 Beta to see if I need to update any settings in the guide.

    Glad you got it working — yes the attitude of those that haven’t found the joy of Mac can be rather negative at times. I think last week at a presentation I heard, “I didn’t think they allowed Macs at these events.” I just chuckled.

  9. DaveA Says:

    Appreciate the optimization tips here. I’m running this 2003 server setup on a Dual 3Hz Mac Pro with 10GB of RAM & dual Cinema display 30’s along with 3 Ubutu servers for .NET & Lamp development. It’s sick.

    I feel sorry for all those developers out there without the sense to check out the Mac platform with open eyes.

Leave a Reply