Developing Windows Phone 8 Apps in a Virtual Machine

I have been doing all of my development activities in a virtualized environment for quite some time. Programming for Microsoft SharePoint Server almost certainly requires a virtual machine but I have come to know that using one is convenient regardless of the target platform. Virtualization makes it easier to do backups and to hand over my work to another developer if need be.

When I had to do a project targeting Windows Phone 8, I found out that the system requirements for building a developer environment requested a dedicated host machine in order to successfully run the Windows Phone 8 emulator which is a virtual machine on Hyper-V itself.

Unhappy as I was with this requirement, I searched for workarounds and I found here a complete dummy-level detailed article on how to build and configure a virtual machine for developing Windows Phone 8 apps. Almost all steps are quite trivial for someone dealing with virtualization on a daily basis so I will just summarize the main caveats.

Hardware and Software Requirements

First of all, the hardware requirements to set up the environment are a 64-bit machine with Hyper-V capability running. You also need at least 4GB free RAM and 40GB disk space to assign to the virtual machine.

Then you need to have 64-bit host operating system. I did this with Windows 7 64-bit but you can of course use Windows 8 64-bit or a server OS as a host. Besides, from software requirements’ point of view, you also need Windows 8 Pro 64-bit or higher to install as OS for the virtual machine.

Last but not least, you need to have VMWare Workstation 9 or higher to set up and run the virtual machine. I also extensively use the free Virtual Box but unfortunately at the time of writing this article it does not support running a virtual machine inside another virtual machine.

Create the Virtual Machine

Start the wizard to create a virtual machine. The first step is to select Custom (advanced) set-up so you have full control of all the settings:

New VM Custom Installation

In the second step leave the hardware compatibility setting to its default which would typically be the highest available option – in my case Workstation 10.0. Then select to install the operating system later:

New VM OS Installation

After that specify the type and version of the guest operating system – in this case Windows 8 64-bit:

New VM OS Type

Next give a name to your virtual machine and specify the location for its files:

New VM Name

Configure the virtual machine processors:

New VM Processors

Then specify how much memory should be allocated to the machine. I chose 4GB which is enough for a decent development experience:

New VM Memory

For network type, use network address translation (NAT), so that the virtual machine shares the host’s IP address and network connection.

In the next step leave the default I/O controller selected and after that choose to create a new virtual disk. The default and recommended disk type is SCSI – just leave it like that.

Specify the disk capacity to at least 40GB. I chose to double that and allocate 80GB disk space because expanding a disk later is slow and tedious. I also prefer to store the virtual disk as a single file:

New VM Disk

In the next step specify the location where the virtual disk will be stored.

You are almost done creating the new virtual machine. The last step is to choose to customize hardware so you are able to set one advanced option of the set-up:

New VM Customize Hardware

Make sure the option “Virtualize Intel VT-x/EPT or AMD-V/RVI” is checked as it provides virtualization capability to the newly created virtual machine, thus making it possible to run another virtual machine:

New VM Virtualization

Back in the last step select Finish. You have now completed the wizard and you have the new virtual machine in place.

Edit the Virtual Machine Configuration File

Before proceeding with the installation of the guest OS, there is a small change that you need to do manually in the virtual machine configuration file. Close VMWare Workstation, go to the folder where the virtual machine files are stored, find the file with extension .vmx and open it in an editor of your choice. Then set the hypervisor.cpuid.v0 setting to FALSE:

New VM Edit VMX File

Save the file and open VMWare Workstation again.

Install the Guest OS

Mount the installation media of Windows 8 to the virtual machine CD/DVD drive:

New VM Install OS

Then start the virtual machine and follow the set-up instructions to install the guest OS.

Once that is complete you also need to install VMWare Tools and then restart the virtual machine.

Enable Hyper-V

In the guest OS open Control Panel and then Programs and Features. Select the option to Turn Windows features on or off:

New VM Windows Features

In the dialog that pops up select both Hyper-V features:

New VM Enable HyperV

You are done!

Now install Visual Studio 2012 and Windows Phone 8 SDK. When you create your mobile project and hit F5, you will have the emulator up and running (although it might take a while to load):

New VM Running Emulator

Enjoy creating mobile apps!

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>