In the previous recipe, you completed your first XNA Windows Phone Game. In this recipe, you will learn more details on how you can deploy your Windows Phone application on the emulator or device.
When you build the Windows Phone 7 project, in the Output window, you will see the building messages similar to the following screenshot:
Here, you may be curious about Xap packaging. A .xap
is a simple file similar to a .zip
file, renamed to .xap
. It contains the app and all relevant dependencies. There are a number of possible .xml
files that could be included inside .xap
, such as required security access level.
For better understanding, you could change the extension from .xap to .zip
and use WinZip to extract the .zip
file. Several necessary information will be presented such as the content directory with .xnbl
binary files, dependency files with .dll
extension, configuration xml
files, an xml
file named AppManifest
, and so on. The xaml
file is very important for Windows Phone 7 applications. This file provides the emulator or device with the application start-up information, the entry point, and the dependency.
After project building, the next step is to deploy your Windows Phone 7 XNA application to the device or emulator. The direct method is by using Visual Studio Deploy Options, as shown in the following screenshot:
In the drop-down list, you could choose Windows Phone 7 Emulator or Windows Phone 7 Device. If you are a member of App Hub, which is free for students and is charged at $99 for regular users, you can successfully deploy to the real device or the emulator. Otherwise, you can choose the emulator as the test platform.
If using an emulator, Visual Studio 2010 will boot the emulator first, and then initialize (this may take a long time if the user's PC does not have hardware virtualization enabled.) The next step is to copy the .xap
file to the emulator and execute it.
If using the device for the first time, the preparation work is a little complex (I promise this is only once), as follows:
1. The first step is to check if the Zune software is installed on your computer. (If the Zune software has not been installed, you can download it from http://www.zune.net/en-US/products/software/download/default.htm).
Besides this, you need to make sure that your phone has loaded the proper device drivers. At this point, you are now ready to start publishing your custom app to the phone.
2. Next, you will need to click Start | All Programs | Windows Phone Developer Tools | Windows Phone Developer Registration. You will see a screen as shown in the following screenshot. You can use the Windows Live ID that you linked to. You can also unregister the device.
Wow! All the preparation work is over now. It is now time for the final step, that is deploy. Open Visual Studio 2010 and choose Windows Phone 7 Device in the drop-down list.
3. Run the application.
4. When you have done this, on your Windows Phone, you will need to slide over to the Application list page with a right direction button at the top-right, and search for the application you named before. Touch it and run the application.