Windows apps
Collapse the table of content
Expand the table of content

Windows 8.1 Store apps: Ensure that resources are installed on a device regardless of whether a device requires them

 
Applies to Windows and Windows Phone

By including a variety of resources in an app package, you can ensure that they'll all be installed with your app on every device, regardless of which resources are required when the app is installed. For example, you can ensure that user-interface strings in multiple languages are installed with your app, not just the language that matches the user language preference of the device. If you use this strategy, users can change language preferences or other settings without being connected to the Internet, and their devices can switch to the best resources for the new settings.

Including resources in an app package increases the size of the app. If you want to reduce the size of your app, include resources in resource packages that users can download later. For most apps, resource packages give users get the best experience with the smallest footprint, but resource packages might not be appropriate for some apps such as multilingual dictionaries, translation tools, or other apps that language to be changed on-the-fly. Those apps can include a variety of resources in an app package.

You can include resources in an app package 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.

  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 the XML File template, name the file priconfig.packaging.xml, and then click Add.

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

    <packaging>
        <autoResourcePackage qualifier="Language" />
        <autoResourcePackage qualifier="Scale" />
        <autoResourcePackage qualifier="DXFeatureLevel" />
    </packaging>
    
  4. Remove the line of XML that represents the category of resources that you don’t want to include in a resource pack. The following example shows the contents of the priconfig.packaging.xml file after the Language qualifier is removed.

    <packaging>
        <autoResourcePackage qualifier="Scale" />
        <autoResourcePackage qualifier="DXFeatureLevel" />
    </packaging>
    

    In this example, all language resources will be included in the app packages of your app bundle, and users will download them regardless of user language preference of the device.

  5. Save and close the priconfig.packaging.xml file.

  6. If you remove the Language qualifier, add another XML file to your project named priconfig.default.xml and replace the contents of that file with the following XML.

    <default>
      <qualifier name="Language" value=Value />
    </default>
    
    System_CAPS_noteNote

    You don’t have to add a priconfig.default.xml file to your project if you remove the Scale or DXFeatureLevel qualifiers and you don’t remove the Language qualifier.

    Replace the Value placeholder with the language code of each language resource that you want to include in an app package. The following example shows how the XML might appear after you’ve replaced the Value placeholder of the language qualifier with a list of language codes.

    <default>
      <qualifier name="Language" value=”en;ja;de” />
      </default>
    
  7. In Solution Explorer, click the priconfig.packaging.xml file.

  8. 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.

  9. If you’ve added a priconfig.default.xml file to your project, set the Build Action property of that file to None, the Package Action property to None or the Content property to False depending on the language of your project.

  10. On the Build menu, click Build Solution, and then create the app package.

    In the Select and Configure Packages page of the Create App Packages wizard, choose to generate an app bundle for your package. See Create a Windows 8.1 app package.

  11. In the ProjectFolder\obj\ReleaseConfiguration folder, open the split.priconfig.xml file in Notepad.

  12. Verify that the qualifiers that you removed don't appear in the list of resource qualifiers.

Renaming the priconfig.packaging.xml file

You can name the configuration file anything you want. But if you name it anything other than priconfig.packaging 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.

    <AppxPriConfigXmlPackagingSnippetPath>FilePath</AppxPriConfigXmlPackagingSnippetPath>
    
    System_CAPS_importantImportant

    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, and then click Reload Project.

  6. Build the solution, and create the package.

System_CAPS_noteNote

If you’ve added a priconfig.default.xml file to your project, you can rename that file as well. For information about how to rename that file, see Renaming the priconfig.default.xml file.

  1. Open the project file of your 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.

    <AppxBundleAutoResourcePackageQualifiers>Language|Scale|DXFeatureLevel</AppxBundleAutoResourcePackageQualifiers>
    
  3. From this line of XML, remove the category of resources that you don’t want to include in a resource pack. The following example shows the line of XML after the Language qualifier is removed.

    <AppxBundleAutoResourcePackageQualifiers>Scale|DXFeatureLevel</AppxBundleAutoResourcePackageQualifiers>
    

    In this example, all language resources will be included in the app packages of your app bundle, and users will download them regardless of the user language preference of the device.

  4. If you remove the Language qualifier, add the following line of XML between the opening and closing tags of the first <PropertyGroup> element.

    <AppxDefaultResourceQualifiers>Language=Value</AppxDefaultResourceQualifiers>
    
    
    System_CAPS_noteNote

    You don’t have to add this line if you remove the Scale or DXFeatureLevel qualifiers and you don’t remove the Language qualifier.

    Replace the Value placeholder with the language code of each language resource that you want to include in an app package. The following example shows how the XML might appear after you’ve replaced the Value placeholder of the language qualifier with a list of language codes.

    <AppxDefaultResourceQualifiers>Language=en;ja;de</AppxDefaultResourceQualifiers>
    
    
  5. Save and close the project file. Then, reload the file in Visual Studio.

  6. Build the solution and then create the app package.

    In the Select and Configure Packages page of the Create App Packages wizard, choose to generate an app bundle for your package. See Create a Windows 8.1 app package.

  7. In the ProjectFolder\obj\ReleaseConfiguration folder, open the split.priconfig.xml file in Notepad.

  8. Verify that the qualifiers that you removed don't appear in the list of resource qualifiers.

Show:
© 2018 Microsoft