In this article, we are going to see how to build the Window Phone to get the package (.XAP ) file and deploy the application to a device or to an emulator for testing the application before publishing it to the marketplace. For simplicity, we will take the sample project that we developed in our earlier articles to build and deploy the application.
Here, we are going to see both the approaches of deploying the application to the device directly. In addition, we are going to see the approach of deploying it to the Emulator (Virtual Device) to test the same and move it to the marketplace. Let us begin the process on how to achieve the above tasks.
Open the Sample project (WpHelloWorld) in visual studio 2010 and we can see the application in the ready state as shown in the screen below.
Now, we are ready to build the application and check if the build is successful to proceed further and test the application in any of the ways i.e. using the Emulator or using the physical device. First, let us deploy the application to the Windows Phone 7 Emulator. To deploy, first go to the View Menu in Visual Studio 2010 and select Output Window as shown in the screen below.
We can also use the shortcut key Ctrl + W, O to open the Output windows. Now, let us build the project and see if we get any compilation errors. If we have any errors, we will get the errors displayed in the output window, which we opened. To build the project you can either debug or press SHIFT + F6 key combination to compile the project in the solution. Pressing BUILD Solution will start the build process as shown in the screen below.
Once the build is successful without any errors, we can see the build result in the same Output window as shown in the screen below.
Now we are ready with the application with successful builds. To deploy the application, we need to select the media on which we need to deploy. We will first target the deployment to the Windows Phone 7 Emulator, to do this, ensure that Windows Phone 7 Emulator is selected in the Select Device drop down next to the Start Debugging button on the toolbar as shown in the screen below.
Now we are well set to run the application. To do that, press F5 to start the application to be deployed to the Emulator. Initially, it will take quite some time to load the application as shown in the screen below.
Once the application is loaded to the Emulator, we can see the working model as shown in the screen below. We can use it directly to test the application and the navigation used in the application.
Now we will see how to test the application on the real physical device. To do that, we need to have a real Windows Phone 7 device and Zune software running on the development machine to connect and upload the application to the device. First, we need to select the Windows Phone 7 Device in the Visual Studio IDE as shown in the screen below.
Once we select the deployment stage as Windows Phone 7 Device, run the application by pressing F5 directly. If the required software are installed correctly and the physical device is connected to the development machine, then the deployment process will be started correctly. Else we will get the below error.
Therefore, in this article we have seen how to deploy the application on the virtual device or to the physical device.