Freigeben über


XAML Resource Packager (Compact 2013)

10/26/2015

The XAML Resource Packager (XRPack.exe) is the part of the Windows Embedded Compact 2013 build system that is responsible for turning your XAML and project resources into an application package for the XamlRuntime to use on the device.

When you build an application, XRPack searches the XAML and the project file to locate all of the resources in the project. It assigns a resource ID to each resource it discovers and includes it in the resource file. The build process produces a resource (.res) file, which contains the strings, images, and XAML from the project, and an executable (.exe) file that accesses the resource file.

If any resource is missing, XRPack will generate an error. The application can load and run the compiled resource file much faster than it could a collection of uncompiled resources.

You can manually select files for XRPack to search by running XRPack at the command line, but we recommend that you use Windows Embedded XAML Tools, which automatically runs XRPack on the original Visual Studio 2013/Visual Studio 2015 or Blend project (.csproj). XRPack does not require you to modify any of the project files. However, if your project will be localized or themed, consider specifying the resource IDs in your project files to keep them consistent throughout the development of your project.

XRPack cannot generate resource IDs if the root element in the XAML file does not contain an x:Class or xrpack:ClassResourceId attribute. Manually edited files may not have an x:Class attribute in the root element. Such files may build in Expression Blend but will fail to build in XRPack. Add an x:Class or xrpack:ClassResourceId attribute to the root element to fix the build error.

Warning

Ensure that your device does not attempt to load Binary XAML (BAML) files from untrusted sources. If the device supports any technique in which BAML files can be downloaded to the device from the Internet, we recommend that you design the application to load BAML only from signed binaries. The easiest way to do this is to embed the resource file created by XRPack into a .dll or .exe file, which you then sign. This way, before loading any BAML or XAML design resources, the application first verifies that it will be loading them from a signed binary, then checks the signature to make sure it is trusted, and finally loads the BAML or XAML.

Example

The following example sources file shows how to invoke XRPack within the build system.

File sources

1:
2:    TARGETNAME=HelloWorld
3:    TARGETTYPE=PROGRAM
4:    RELEASETYPE=PLATFORM
5:    
6:    ENABLE_OPTIMIZER=0
7:    
8:    INCLUDES= \
9:        $(_WINCEROOT)\public\common\sdk\inc; \
10:        $(_WINCEROOT)\public\common\oak\inc; \
11:    
12:    SOURCES= \
13:        HelloWorld.cpp \
14:    
15:    TARGETLIBS= \
16:        $(_COREDLL)\
17:        $(_XAMLRUNTIME) 
18:    
19:    XRPACK_NAME=HelloWorld
20:    XRPACK_PROJECT=Assets\HelloWorld\HelloWorld.csproj
21:    XRPACK_ARGS=\Verbosity=3

Lines 19 and 20 show how to specify the project name, and the location of the .csproj file. Line 21 shows how to specify command-line arguments for XRPack. Set XRPACK_NAME to the .csproj file name for consistency. The build system will use it for the /TargetRes and /TargetHeader command-line parameters.

Command-Line Parameters

You can run XRPack from the command line if you need to run it outside of the build system. XRPack processes command-line parameters in order, from left to right.

The following list shows the command-line parameters.

  • -?, -h, -Help
    Primary Help screen.
  • -??
    Extended help on a given command; for example, -??=AutoScan.
  • -AddIgnore
    Specify a file or directory to ignore while scanning for files. Relative paths are not supported; for example, xrpack /AddIgnore=MyOldFile.xaml /AddIgnore=UserDir /S /AutoScan=xaml. Will ignore any file or directory that matches App.xaml or UserDir in the xaml directory or its subdirectories.

    An -AddIgnore rule will apply to all subsequent scan rules until canceled by a -RemoveIgnore rule.

  • -AddResScanRule
    Specify a file pattern for resource scans; for example, *.png.
  • -AppXaml
    Use as application XAML file if present.
  • -AutoScan
    Specify a directory to scan for all XAML.

    To include subdirectories specify -S first; for example, xrpack -S -AutoScan=thisDirectory.

  • -AutoScanRes
    Specify a directory to scan for resource files only.
  • -BamlOff
    Turn BAML compiler off (default).
  • -BamlOn
    Turn BAML compiler on.
  • -C
    Ignore timestamps on intermediate files.
  • -CmdLineDump
    Show values processed by command-line manager.
  • -ImageCompress
    Convert resource file to compressed bitmap. This affects only files that follow this parameter.

    For example:

    xrpack /ResID=15 /ImageCompress /ResFile=Picture1.png

    /ResID=20 /ImageCompress /ResFile=Picutre2.png

  • -ImageNoCompress
    Convert resource file to normalized bitmap. This affects only files that follow this parameter.

    For example:

    xrpack /ResID=15 /ImageNoCompress /ResFile=Picture1.png

    /ResID=20 /ImageNoCompress /ResFile=Picture2.png

  • -ImageNoConvert
    Do not convert resource file to a normalized or compressed bitmap (default) This affects only files that follow this parameter.

    For example:

    xrpack /ResID=15 /ImageNoConvert /ResFile=Picture1.png

    /ResID=20 /ImageNoConvert /ResFile=Picutre2.png

  • -IntermediateFiles
    Specify the directory in which to place intermediate files.

    Warning

    Depending on the value used, some files in the specified directory may be overwritten.

    • Using "." will overwrite the source files.
    • Using an absolute path, for example, D:\sd\MyFolder, will overwrite XAML files with the same name.
    • Using a relative path, for example, OBJ\xrpack, will not overwrite files. XRPackwill create a hierarchy similar to the original location of the files to avoid overwriting the files.
  • -LogAll
    Create extremely verbose log files.

    Turns on diagnostic logging in the BAML compiler. Sets -verbosity=10 after other processing. To see verbose output before processing, explicitly set -verbosity=10; for example, xrpack /LogAll /Verbosity=10 /AutoScan=xaml.

  • -NoLogo
    Suppress the copyright message.
  • -NoResourceCompile
    Do not call RC.exe.
  • -NoStringTables
    Do not add found or marked strings to string tables.
  • -OutputFiles
    Location for output files.
  • -Project
    Use a .csproj file to define the resource set.
  • -RemoveIgnore
    Remove a rule created by using -AddIgnore.

    By default, XRPack uses predefined ignore rules for "AppManifest.Xaml", "bin", "obj", and "Properties". These are directories and files in an Expression Blend project that you usually do not need to include.

  • -RemoveResScanRule
    Remove a specific file pattern, which was set by using -AddResScanRule, for resource scans.
  • -ResFile
    Specify a resource file to add to the list of resources.
  • -ResID
    Specify a starting resource ID. /ResID should precede a command that generates an ID, -AutoScan, -AutoScanRes, or -XamlFile; for example, xrpack /ResID=15 /XamlFile=TheXaml.Xaml /ResID=1000 /AutoScan=xaml.
  • -Root
    Set the root for resolving resources.
  • -S
    Scan subdirectories in auto scan modes. This affects only scan parameters that follow it.
  • -TargetHeader
    Specify the header (.h) file.
  • -TargetRC
    Specify the name of the resource (.rc) file.
  • -TargetRes
    Specify the name of the compiled resource (.res) file.
  • -Verbosity
    Amount of information to display.

    0 = Fatal errors only.

    1 = Normal informational output (default).

    2 = Displays file information.

    3 = High informational output.

    10 = Diagnostic informational output.

  • -XamlFile
    Add a specific file to the list of XAML files.
  • @
    Specify a response file that contains command-line parameters; for example, @MyResponseFile.txt. You can specify multiple response files and use them in conjunction with other parameters. However, if you use response files recursively, it will create a circular dependency that will cause XRPack to stop responding.

    The syntax in the response file is identical to the command line. White space is ignored and any line beginning with "#" is ignored as a comment.

Remarks

For more information about XRPack XAML syntax, see Getting Started with XAML for Windows Embedded.

To use XRPack XAML syntax in a Blend for Visual Studio project, you must add the xrpack namespace by adding the following code to the UserControl root element:

xmlns:d="https://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="https://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:xrpack="https://schemas.microsoft.com/windowsembedded/xaml/packaging"
mc:Ignorable="d

For more information about XAML namespaces, see Silverlight XAML Namespaces, and Mapping XAML Namespaces as Prefixes at MSDN.

To enable a XAML for Windows Embedded application in the run-time image to use a localized resource file, add the localized resource file to a directory that the build process uses for localized resources. Then, the build process can merge the localized resources into the run-time image.

The following list shows directories that the build process uses for localized resources.

  • %_WINCEROOT%\Public\Common\Oak\Lib\microprocessor\Build Configuration\Locale ID
  • %_WINCEROOT%\Public\Ie7\Oak\Lib\microprocessor\Build Configuration\Locale ID
  • %_WINCEROOT%\Public\Shell\Oak\Lib\microprocessor\Build Configuration\Locale ID
  • %_WINCEROOT%\Public\Directx\Oak\Lib\microprocessor\Retail\Locale ID
  • %_WINCEROOT%\Public\Apps\Oak\Lib\microprocessor\Build Configuration\Locale ID

See Also

Reference

Platform Builder Command Line Tools
XRPack Errors

Other Resources

XAML for Windows Embedded