.NET development in OSX
I’ve recently split my working week between two jobs and one of the perks is that I am now the proud owner of a Macbook Pro. However, both companies I work for use .NET. This means that I need to be able to run the websites I’m working on locally; and that requires me to use Windows, so I can run IIS.
Setting up the Virtual Machine
The first thing to do is go ahead and set up Windows in a Virtual Machine exactly as you would normally. I would recommend installing XP over Windows 7 because it will have a smaller footprint, and you don’t really need to ‘use’ it, just run it in the background.
If you’re tempted by IIS7’s ability to run multiple sites (something you cannot do with XP by default), I recommend IISAdmin.NET; this handy utility allows you to switch between multiple sites with IIS5.
There is one required setting, and that is that the Virtual Machine’s network connection is bridged, not using NAT. This will allow us to assign the Virtual Machine a static IP, which is vital if we’re to make working in OSX painless.
Sharing files between the two
The other choice you have to make is whether or not you want to share your OSX files. I’ve not bothered because I’m going to share the other way round – writing to the VM’s hard disk, instead of reading them from the Mac in Windows. Mac shares are seen by Windows as a network drive and IIS has some serious issues with these.
I have multiple sites running, and I stick them all in C:\Projects. If you’re just running with defaults and a single site, they’ll be in C:\Inetpub\wwwroot. Navigate to these folders in Windows Explorer and right-click. Choose ’sharing and security’ and set this folder to be shared and allow other users to edit these files. Give the share a sensible name like ‘Server‘ or ‘Projects‘.
Check your VM is all set up
You should now be able to
- Access the Internet in the VM
- Run your site in the VM as localhost
- Ping your VM’s IP from terminal (type ping x.x.x.x in Terminal, where x.x.x.x is the static IP assigned to the VM)
- The folder you store your site files in should be shared (depicted by a hand holding the folder icon)
As your VM has a static IP, it is connected to the internet; so I wouldn’t recommend completely disabling any firewall. You will need to configure your firewall to allow you to be able to access your VM from the Mac, but as there are so many different possibilities I can’t go into details here.
Viewing your ‘local’ site in OSX
You should now be able to access your site running under IIS in the virtual machine in OSX. Open a browser and go to the IP address you assigned the the VM. You should see the .NET site running.
Now we’ll map this IP address to a nice name; so I can access this site as http://dev/ or similar. Open your text editor of choice and go to the ‘Open’ dialogue (⌘-O) and then type ⌘-shift-G to open the ‘Go to folder’ dialogue. Type ‘/etc/‘ and open the ‘hosts’ file. Add your ‘nice’ name and the IP you assigned, save, close.
Viewing your ‘local’ site files in OSX
Open finder and hit ⌘-K. This brings up the ‘Connect to Server‘ dialogue. I mapped the host name ‘mvc‘ to my VM’s IP address, and shared my files as ‘Projects‘; so I will connect to ‘smb://mvc/Projects‘.
The username and password you connect as should have not affect anything; you can connect as a guest if you so wish. Anyway, you should now be able to view and edit your .NET site in OSX!
I’m loving it
I’ve only had a few weeks with this setup but I can confirm I am nothing short of delighted with it. I currently am in love with Coda and TextMate. Coda seems to have the best ‘out of the box’ syntax highlighting for .NET / C# code, and that’s why I use it.
I’m also going to look into auto-mounting the shares but because I use my job for three ‘jobs’ (Abacus, GigJunkie and MooTools) this isn’t really practical. I also foresee some potential problems with source control and permissions; but I’ll tackle these issues as and when they come around.
Hopefully this post was of vague interest and help to some of you looking to achieve the same. It works well for me and I hope it works well for you too.
2 Comments
Jump to comment form | comments rss [?] | trackback uri [?]