Not that long ago, I moved my development setup from one Windows machine to another.[ref]Don't worry, I still use my Mac on a regular basis as well. I value my ability to work across and between both systems, so while my Mac is my primary out-of-office machine, I use a Windows PC regularly in my home office.[/ref] Since I wanted the ability to easily develop for Windows Phone and WinRT, I made sure to set up Windows 8.1 Pro and its built-in Hyper-V provider.

This also meant I had to move my VVV setup away from VirtualBox and on to Hyper-V. Doable, but with a couple of issues.

Directory Mapping

The first issue I faced was with symlinks.

For several of my projects, I set up a unit test repository that includes the main project as a Git submodule. This test repo is entirely separate from WordPress, so I need to symlink the main project to either the [cci]/themes[/cci] or [cci]/plugins[/cci] directory to get things to work right.

In my old VirtualBox setup, this involved creating a symlink inside the virtual machine itself. The link showed as broken in Windows, but was traversed properly within the host. A minor inconvenience, but it worked.

Once I swapped to Hyper-V, though, the link was entirely broken.

The Hyper-V setup with Vagrant uses Samba (SMB), a protocol fairly similar to NFS, to mount and share host directories within the guest. For security reasons, Samba explicitly disables symlinks. For a few days, I thought I was sunk.

Then I remembered how directory junctions work in Windows and tried setting the link through the host's file system.

Voila! Success. Paths within the guest OS now appear as expected, and Linux has no idea it's following a phony link and everyone's happy.

Dynamic Hosts File

In a vanilla VVV setup, all of your new domains are mapped to a static IP address - hard coded into the Vagrantfile and pretty easy to remember. If you have Vagrant's Hostsupdater plugin installed, then these domains (and the static IP they map to) are all automatically added to your system's [cci]hosts[/cci] file upon starting the machine.

Hyper-V, however, does things a bit differently.

While creating, the system will ask you which network adapter to use for the virtual machine (unlike VirtualBox, it doesn't create its own adapter). If you select your real adapter - the only way for the guest to access the network - then your virtual machine will be granted a dynamic IP address on your network.

The machine will work just fine. You can add entries to your hosts file just fine. But the Hostsupdater plugin will add a bunch of entries for the (now invalid) hard-coded IP address in the Vagrantfile.

Luckily, the plugin is written in Ruby (a language I know and love), so I was able to hack around a bit to get the plugin to work with Hyper-V's dynamic IP address. A pull request I submitted last week makes my modifications available to everyone.

VVV Works with Windows

The WordPress community tends to come down pretty hard on developers using Windows. Too often the answer to "how do I set up X on Windows" is "go buy a Mac, then come ask again."

Hopefully my initial work with Windows, Vagrant, and VirtualBox helps to solve some of these issues. If you'd rather work with Windows' native virtualization (Hyper-V), then this article and my previous walk-through should help get you started.

Let's stop bickering over our toolkits and go build something awesome!