วันพุธที่ 9 พฤษภาคม พ.ศ. 2555

How to: Specify a Target Version or Upgrade Projects for Windows Phone

How to: Specify a Target Version or Upgrade Projects for Windows Phone

When you use the Windows Phone SDK 7.1 to create a new Windows Phone application or game, you can target Windows Phone OS 7.0 or Windows Phone OS 7.1. For an existing Windows Phone OS 7.0 application or library project, you can continue targeting Windows Phone OS 7.0 or you can upgrade the application to target Windows Phone OS 7.1. The following table lists the Windows Phone SDK support options to assist you in choosing the version you want to target. For more information about application compatibility, see Windows Phone OS Application Compatibility.
Windows Phone SDK VersionTarget Windows Phone OS VersionCreate or Open ProjectsDeploy or Debug ProjectsUse Windows Phone OS 7.1 Features
7.07.0green check markgreen check markWindows Phone Emulator 7.0 and device with backward compatibilityred x
7.07.1red xred xred x
7.17.0green check markgreen check markred x
7.17.1green check markgreen check markgreen check mark

The following illustration summarizes the deployment options when developing applications using the Windows Phone SDK 7.1.
Deployment support using tools.
You can set the target version for a new Windows Phone application or game project by using the target version dialog box provided in Visual Studio. An application solution can contain projects that target different Windows Phone versions, but projects in a game solution must all target the same version of Windows Phone. This means that for an application project, a Windows Phone OS 7.1 project can reference a Windows Phone OS 7.0 project; however, a Windows Phone OS 7.0 project cannot reference a project that targets Windows Phone OS 7.1. The following illustration shows the project reference support for applications.
Project reference options

To set the target version

  1. In Visual Studio, on the File menu, select New Project.
  2. From the Installed Templates list, select Silverlight for Windows Phone or XNA Game Studio 4.0 and then select one of the provided templates.
  3. Specify a name for the project and then click OK.
    The target version dialog box appears. The following illustration shows the target version dialog box for an application. The dialog box for a game is very similar.
    platform picker dialog
    Caution noteCaution:
    When you create a project using one of the new templates added in Windows Phone SDK 7.1, the target version dialog box does not appear. These projects will target Windows Phone OS 7.1.
  4. In the Target Windows Phone OS Version drop-down list, select Windows Phone OS 7.0 or Windows Phone OS 7.1 to specify the target version for your application and then click OK.
You can upgrade an existing Windows Phone application or game project that targets Windows Phone OS 7.0 to target Windows Phone OS 7.1. However, it is important to note that once you upgrade a project, you cannot later downgrade it back to Windows Phone OS 7.0. Because of this, you should create a back-up copy of the project before you upgrade it. When you upgrade a game project, the entire solution will be upgraded.
Projects upgraded from Windows Phone OS 7.0 to Windows Phone OS 7.1 may need additional adjustments if Windows Phone OS 7.1 features are added to the application. An upgraded project does not add in any of the Windows Phone OS 7.1 references. It may be necessary to add references to your project for new APIs that you want to use.
An upgraded project does not add capabilities to the application manifest file. If new Windows Phone OS 7.1 features are added to the application, it may be necessary to manually edit the manifest file or run the Capability Detection Tool.

To upgrade an existing Windows Phone OS 7.0 application

  1. Open the Windows Phone OS 7.0 application project you want to upgrade in Visual Studio.
  2. In Solution Explorer, select the project.
  3. Right-click the project and select Upgrade to Windows Phone 7.1 in the context menu. The project will be upgraded to target Windows Phone OS 7.1.
    -or-
  4. On the Project menu, select the Properties item to open the project designer.
  5. On the Application tab, change the Target Windows Phone OS Version drop-down list to Windows Phone OS 7.1. The project will be upgraded to target Windows Phone OS 7.1.
    The following illustration shows the target version drop-down list.
    Target Windows Phone Version
  6. If you add Windows Phone OS 7.1 functionality to the application, you might need to add Windows Phone OS 7.1 references.
  7. If you add Windows Phone OS 7.1 functionality to the application, you might need to update the capabilities in the application manifest file. For more information, see Application Manifest File for Windows Phone and How to: Determine Application Capabilities.

To upgrade an existing Windows Phone OS 7.0 game

  1. Open the Windows Phone OS 7.0 game project you want to upgrade in Visual Studio.
  2. In Solution Explorer, select the project.
  3. Right-click the project and select Upgrade Windows Phone Projects in the context menu.
    -or-
    On the Project menu, select the Upgrade Windows Phone Projects menu.
    The Upgrade Windows Phone Projects dialog box appears.
  4. Click Upgrade to upgrade the project or Cancel to cancel the upgrade process.
  5. If you add Windows Phone OS 7.1 functionality to the application, you might need to add Windows Phone OS 7.1 references.
  6. If you add Windows Phone OS 7.1 functionality to the application, you might need to update the capabilities in the application manifest file. For more information, see Application Manifest File for Windows Phone and How to: Determine Application Capabilities.
The easiest way to create an application or game that runs on both Windows Phone OS 7.0 and Windows Phone OS 7.1 is to create an application that targets Windows Phone OS 7.0, but test it on both devices.

To create an application that runs on both Windows Phone OS 7.0 and Windows Phone OS 7.1

  1. Using the Windows Phone SDK 7.1, create an application that targets Windows Phone OS 7.0.
  2. Test the application using the Windows Phone Emulator 7.1 provided with the Windows Phone SDK 7.1.
  3. Deploy and test the application on a Windows Phone OS 7.0 device and a Windows Phone OS 7.1 device.
If you want to create an application that runs on both Windows Phone OS 7.0 and Windows Phone OS 7.1, you can create two versions of your application, one that targets Windows Phone OS 7.0 and one that targets Windows Phone OS 7.1. However, this solution results in duplicate code to maintain in two separate applications. An alternate approach is to factor common logic into a library project that targets Windows Phone OS 7.0 and reference this project from the Windows Phone OS 7.0 and Windows Phone OS 7.1 application projects. You can only use this approach with application projects because a Windows Phone game requires all projects in a solution to target the same version of the Windows Phone OS.

To use the same code in applications that target both Windows Phone OS 7.0 and Windows Phone OS 7.1

  1. Create a Windows Phone library project that targets Windows Phone OS 7.0.
  2. Add most of the business logic to this project. You must only use features supported in Windows Phone OS 7.0 for this project.
  3. Create two application projects, one that targets Windows Phone OS 7.0 and one that targets Windows Phone OS 7.1.
  4. Add a reference to the Windows Phone library project from each application project.
  5. Add the necessary UI elements and version specific logic to the application projects.
  6. Test both applications using the correct device for the target platform of that application.

ไม่มีความคิดเห็น:

แสดงความคิดเห็น