Windows 8.1 Store apps: Specify the default resources that are installed on a device

 

Applies to Windows and Windows Phone

When a user installs an app, the operating system of the device tries to identify and install various resources in the app, such as user-interface strings and resolution-specific images, that are appropriate for the device on which the app is being installed. For example, an app might have strings in Spanish that can be installed on devices that are set to an appropriate locale. However, your app might not have appropriate resources for every device and locale that your users have. In those cases, the operating system of the user’s device will, by default, install resources that are appropriate for your development computer, its locale, and other settings. If you want different resources to be installed on the device, you can specify them by adding a configuration file. Alternatively, if you’re comfortable editing your project file directly, you can accomplish this task by doing that as well.

Option 1: Add a configuration file to your solution

  1. In Solution Explorer, right-click the project for your app, point to Add, and then click New Item.

  2. In the Add New Item dialog box, click XML File, name the file priconfig.default.xml, and then click Add.

  3. Replace the contents of the file with the following XML.

    <default>
      <qualifier name="Language" value=Value />
      <qualifier name="Contrast" value=Value />
      <qualifier name="Scale" value=Value />
      <qualifier name="HomeRegion" value=Value />
      <qualifier name="TargetSize" value=Value />
      <qualifier name="LayoutDirection" value=Value />
      <qualifier name="DXFeatureLevel" value=Value />
      <qualifier name="Configuration" value=Value />
      <qualifier name="AlternateForm" value=Value />
    </default>
    

    In the next step, you’ll replace the Value placeholders with valid resource qualifiers. See How to: Name resources using qualifiers (apps using C#/VB/C++ and XAML) or How to: Name resources using qualifiers (apps using JavaScript and HTML).

  4. Replace each Value placeholder with a valid resource qualifier.

    The following example shows how the XML might appear after you’ve replaced the Value placeholders with valid resource qualifiers.

    <default>
      <qualifier name="Language" value="en-us" />
      <qualifier name="Contrast" value="standard" />
      <qualifier name="Scale" value="120" />
      <qualifier name="HomeRegion" value="001" />
      <qualifier name="TargetSize" value="256" />
      <qualifier name="LayoutDirection" value="LTR" />
      <qualifier name="DXFeatureLevel" value="DX9" />
      <qualifier name="Configuration" value="" />
      <qualifier name="AlternateForm" value="" />
    </default>
    
  5. Save and close the priconfig.default.xml file.

  6. In Solution Explorer, click the priconfig.default.xml file.

  7. In the Properties window, change the values of the following properties depending on the language of the project.

    • For C# and VB projects, set the Build Action property to None.

    • For JavaScript projects, set the Package Action property to None.

    • For C++ projects, set the Content property to False.

  8. On the Build menu, click Build Solution.

  9. In the ProjectFolder**\obj\**ReleaseConfiguration folder, open the priconfig.xml file in Notepad.

  10. Verify that the qualifiers that you’ve added appear in the file.

Renaming the priconfig.default.xml file

You can name the configuration file anything you want. But if you name it anything other than priconfig.default xml, you must add a build property to the project file.

  1. In Solution Explorer, right-click the project for your app, and then click Unload Project.

  2. Right-click the project again, and then click Edit AppName**.csproj** or Edit AppName**.vbproj**.

  3. In the project file, add the following line of XML between the opening and closing tags of the first <PropertyGroup> element.

    <AppxPriConfigXmlDefaultSnippetPath>FilePath</AppxPriConfigXmlDefaultSnippetPath>
    

    Important

    Replace FilePath with the path to your configuration file, including the name of the file.

  4. Save and close the project file.

  5. In Solution Explorer, right-click the project, click Reload Project, and then build the solution.

Option 2: Modify the project file (advanced)

  1. Open the project file of the app in Notepad.

  2. In the project file, add the following line of XML between the opening and closing tags of the first <PropertyGroup> element. This XML identifies the resources that the operating system of the device will install if the app doesn't have appropriate resources for a particular device, locale, or other setting.

    <AppxDefaultResourceQualifiers>Language=ValueContrast=Value|Scale=Value|HomeRegion=Value|TargetSize=Value|
         LayoutDirection=Value|DXFeatureLevel=Value|Configuration=Value|AlternateForm=Value</AppxDefaultResourceQualifiers>
    

    In the next step, you’ll replace the Value placeholders with valid resource qualifiers. For example, you'll set the Language qualifier to the {DefaultResourceLanguage} moniker. When you create the app package, Visual Studio will replace this moniker with the value of the Default language property that you can set on the Application tab of the manifest designer. As an alternative, you could also set the language qualifier to a specific locale value, such as en-us. See How to: Name resources using qualifiers (apps using C#/VB/C++ and XAML) or How to: Name resources using qualifiers (apps using JavaScript and HTML).

  3. Replace each Value placeholder with a valid resource qualifier.

    The following example shows how the XML might appear after you’ve replaced the Value placeholders with valid resource qualifiers.

    <AppxDefaultResourceQualifiers>Language={DefaultResourceLanguage}|Contrast=high|Scale=140|HomeRegion=419|TargetSize=256|
         LayoutDirection=LTR|DXFeatureLevel=DX10|Configuration=|AlternateForm=altform-msft-phonetic</AppxDefaultResourceQualifiers>
    
  4. Save and close the project file. Then, reload the project file in Visual Studio.

  5. Build the solution.

  6. In the ProjectFolder**\obj\**ReleaseConfiguration folder, open the priconfig.xml file in Notepad.

  7. Verify that the qualifiers that you’ve added appear in the file.

See Also

Defining app resources (apps using C#/VB/C++ and XAML)
Defining app resources (apps using JavaScript and HTML)
Windows 8.1 Store apps: Ensure that resources are installed on a device regardless of whether a device requires them
App bundles
Deciding whether to generate an app bundle
Resource packages
Resource Management System