MakePri.exe 格式特定索引器MakePri.exe format-specific indexers

本主题介绍 MakePri.exe 工具生成其资源索引时所使用的特定格式索引器。This topic describes the format-specific indexers used by the MakePri.exe tool to generate its index of resources.

备注

当你在安装 Windows 软件开发工具包时检查 UWP 托管应用的 Windows SDK 选项时,会安装 MakePri.exe。MakePri.exe is installed when you check the Windows SDK for UWP Managed Apps option while installing the Windows Software Development Kit. 它将安装到 (的路径 %WindowsSdkDir%bin\<WindowsTargetPlatformVersion>\x64\makepri.exe 和其他体系结构) 的文件夹中。It is installed to the path %WindowsSdkDir%bin\<WindowsTargetPlatformVersion>\x64\makepri.exe (as well as in folders named for the other architectures). 例如 C:\Program Files (x86)\Windows Kits\10\bin\10.0.17713.0\x64\makepri.exeFor example, C:\Program Files (x86)\Windows Kits\10\bin\10.0.17713.0\x64\makepri.exe.

MakePri.exe 通常与 newversionedresourcepack 命令一起使用。MakePri.exe is typically used with the new, versioned, or resourcepack commands. 请参阅 MakePri.exe 命令行选项See MakePri.exe command-line options. 在这些情况下,它索引源文件以生成资源索引。In those cases it indexes source files to generate an index of resources. MakePri.exe 使用各种单独的索引器读取不同的源资源文件或资源容器。MakePri.exe uses various individual indexers to read different source resource files or containers for resources. 最简单的索引器是文件夹索引器,它索引文件夹的内容,如 .jpg.png 图像。The simplest indexer is the folder indexer, which indexes the contents of a folder, such as .jpg or .png images.

通过指定 MakePri.exe 配置文件<index> 元素中的 <indexer-config> 元素标识特定格式索引器。You identify format-specific indexers by specifying <indexer-config> elements within an <index> element of the MakePri.exe configuration file. type 属性标识使用的特定格式索引器。The type attribute identifies the format-specific indexer that is used.

在索引过程中遇到的资源容器通常将它们的内容编入索引,而不是添加到索引自身中。Resource containers encountered during indexing usually get their contents indexed rather than being added to the index themselves. 例如,文件夹索引器找到的 .resjson 文件可能会由 .resjson 索引器进一步编制索引,在这种情况下 .resjson 文件本身不显示在索引中。For example, .resjson files that the folder indexer finds may be further indexed by a .resjson indexer, in which case the .resjson file itself does not appear in the index. 注意 与该容器关联的索引器的 <indexer-config> 元素必须包括在配置文件中才会发生这种情况。Note an <indexer-config> element for the indexer associated with that container must be included in the configuration file for that to happen.

通常情况下,在包含实体(如文件夹或 .resw 文件)上找到的限定符应用到其中的所有资源,如文件夹中的文件,或 .resw 文件中的字符串。Typically, qualifiers found on a containing entity—such as a folder or a .resw file—are applied to all resources within it, such as the files within the folder, or the strings within the .resw file.

FolderFolder

文件夹索引器由文件夹的 type 属性进行标识。The folder indexer is identified by a type attribute of FOLDER. 它索引文件夹的内容,并从文件夹和文件名确定资源限定符。It indexes the contents of a folder, and determines resource qualifiers from the folder and filenames. 它的配置元素符合以下架构。Its configuration element conforms to the following schema.

<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <xs:simpleType name="ExclusionTypeList">
        <xs:restriction base="xs:string">
            <xs:enumeration value="path"/>
            <xs:enumeration value="extension"/>
            <xs:enumeration value="name"/>
            <xs:enumeration value="tree"/>
        </xs:restriction>
    </xs:simpleType>
    <xs:complexType name="FolderExclusionType">
        <xs:attribute name="type" type="ExclusionTypeList" use="required"/>
        <xs:attribute name="value" type="xs:string" use="required"/>
        <xs:attribute name="doNotTraverse" type="xs:boolean" use="required"/>
        <xs:attribute name="doNotIndex" type="xs:boolean" use="required"/>
    </xs:complexType>
    <xs:simpleType name="IndexerConfigFolderType">
        <xs:restriction base="xs:string">
            <xs:pattern value="((f|F)(o|O)(l|L)(d|D)(e|E)(r|R))"/>
        </xs:restriction>
    </xs:simpleType>
    <xs:element name="indexer-config">
        <xs:complexType>
            <xs:sequence>
                <xs:element name="exclude" type="FolderExclusionType" minOccurs="0" maxOccurs="unbounded"/>
            </xs:sequence>
            <xs:attribute name="type" type="IndexerConfigFolderType" use="required"/>
            <xs:attribute name="foldernameAsQualifier" type="xs:boolean" use="required"/>
            <xs:attribute name="filenameAsQualifier" type="xs:boolean" use="required"/>
            <xs:attribute name="qualifierDelimiter" type="xs:string" use="required"/>
        </xs:complexType>
    </xs:element>
</xs:schema>

qualifierDelimiter 属性指定在哪个字符后指定文件名中的限定符,忽略扩展。The qualifierDelimiter attribute specifies the character after which qualifiers are specified in a filename, ignoring the extension. 默认值是“.”。The default is ".".

PRIPRI

PRI 索引器由 PRI 的 type 属性进行标识。The PRI indexer is identified by a type attribute of PRI. 它索引 PRI 文件的内容。It indexes the contents of a PRI file. 你通常在将另一个程序集、DLL、SDK 或类库中包含的资源索引到应用的 PRI 中时使用它。You typically use it when indexing the resource contained within another assembly, DLL, SDK, or class library into the app's PRI.

PRI 文件中包含的所有资源名称、限定符和值都直接在新的 PRI 文件中进行维护。All resource names, qualifiers and values contained in the PRI file are directly maintained in the new PRI file. 但顶级资源映射不在最终 PRI 中进行维护。The top level resource map, however is not maintained in the final PRI. 资源映射合并。Resource Maps are merged.

<xs:schema id="prifile" xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
    <xs:simpleType name="IndexerConfigPriType">
        <xs:restriction base="xs:string">
            <xs:pattern value="((p|P)(r|R)(i|I))"/>
        </xs:restriction>
    </xs:simpleType>
    <xs:element name="indexer-config">
        <xs:complexType>
            <xs:attribute name="type" type="IndexerConfigPriType" use="required"/>
        </xs:complexType>
    </xs:element>
</xs:schema>

PriInfoPriInfo

PriInfo 索引器由 PRIINFO 的 type 属性进行标识。The PriInfo indexer is identified by a type attribute of PRIINFO. 它索引详细转储文件的内容。It indexes the contents of a detailed dump file. 你可以通过使用 /dt detailed 选项运行 makepri dump 的方式产生详细的转储文件。You produce a detailed dump file by running makepri dump with the /dt detailed option. 索引器的配置元素符合以下架构。The configuration element for the indexer conforms to the following schema.

<xs:schema id="priinfo" xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
  <xs:simpleType name="IndexerConfigPriInfoType">
    <xs:restriction base="xs:string">
      <xs:pattern value="((p|P)(r|R)(i|I)(i|I)(n|N)(f|F)(o|O))"/>
    </xs:restriction>
  </xs:simpleType>
  <xs:element name="indexer-config">
    <xs:complexType>
      <xs:attribute name="type" type="IndexerConfigPriInfoType" use="required"/>
      <xs:attribute name="emitStrings" type="xs:boolean" use="optional"/>
      <xs:attribute name="emitPaths" type="xs:boolean" use="optional"/>
    </xs:complexType>
  </xs:element>
</xs:schema>

此配置元素允许可选属性配置 PriInfo 索引器的行为。This configuration element allows for optional attributes to configure the behavior of the PriInfo indexer. emitStringsemitPaths 的默认值为 trueThe default value of emitStrings and emitPaths is true. 如果 emitStringstrue,则 type 属性设置为“字符串”的候选资源包括在索引中,否则从索引中排除。If emitStrings is true then resource candidates with the type attribute set to "String" are be included in the index, otherwise they are excluded. 如果“emitPaths”为 true,则 type 属性设置为“路径”的候选资源包括在索引中,否则从索引中排除。If 'emitPaths' is true then resource candidates with the type attribute set to "Path" are included in the index, otherwise they are excluded.

下面提供了包括字符串资源类型但跳过路径资源类型的配置示例。Here is an example configuration that includes String resource types but skips Path resource types.

<indexer-config type="priinfo" emitStrings="true" emitPaths="false" />

要编入索引,转储文件必须以扩展 .pri.xml 结束,并且必须符合以下架构。To be indexed, a dump file must end with the extension .pri.xml, and must conform to the following schema.

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" >
  <xs:simpleType name="candidateType">
    <xs:restriction base="xs:string">
      <xs:pattern value="Path|String"/>
    </xs:restriction>
  </xs:simpleType>
  <xs:complexType name="scopeType">
    <xs:sequence>
      <xs:element name="ResourceMapSubtree" type="scopeType" minOccurs="0" maxOccurs="unbounded"/>
      <xs:element name="NamedResource" minOccurs="0" maxOccurs="unbounded">
        <xs:complexType>
          <xs:sequence>
            <xs:element name="Decision" minOccurs="0" maxOccurs="unbounded">
              <xs:complexType>
                <xs:sequence>
                  <xs:any processContents="skip" minOccurs="0" maxOccurs="unbounded"/>
                </xs:sequence>
                <xs:anyAttribute processContents="skip" />
              </xs:complexType>
            </xs:element>
            <xs:element name="Candidate" minOccurs="0" maxOccurs="unbounded">
              <xs:complexType>
                <xs:sequence>
                  <xs:element name="QualifierSet" minOccurs="0" maxOccurs="unbounded">
                    <xs:complexType>
                      <xs:sequence>
                        <xs:element name="Qualifier" minOccurs="0" maxOccurs="unbounded">
                          <xs:complexType>
                            <xs:attribute name="name" type="xs:string" use="required" />
                            <xs:attribute name="value" type="xs:string" use="required" />
                            <xs:attribute name="priority" type="xs:integer" use="required" />
                            <xs:attribute name="scoreAsDefault" type="xs:decimal" use="required" />
                            <xs:attribute name="index" type="xs:integer" use="required" />
                          </xs:complexType>
                        </xs:element>
                      </xs:sequence>
                      <xs:anyAttribute processContents="skip" />
                    </xs:complexType>
                  </xs:element>
                  <xs:element name="Value" type="xs:string"  minOccurs="0" maxOccurs="unbounded"/>
                </xs:sequence>
                <xs:attribute name="type" type="candidateType" use="required" />
              </xs:complexType>
            </xs:element>
          </xs:sequence>
          <xs:attribute name="name" use="required" type="xs:string" />
          <xs:anyAttribute processContents="skip" />
        </xs:complexType>
      </xs:element>
    </xs:sequence>
    <xs:attribute name="name" use="required" type="xs:string" />
    <xs:anyAttribute processContents="skip" />
  </xs:complexType>
  <xs:element name="PriInfo">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="PriHeader" >
          <xs:complexType>
            <xs:sequence>
              <xs:any minOccurs ="0" maxOccurs="unbounded" processContents="skip" />
            </xs:sequence>
            <xs:anyAttribute processContents="skip" />
          </xs:complexType>
        </xs:element>
        <xs:element name="QualifierInfo">
          <xs:complexType>
            <xs:sequence>
              <xs:any minOccurs="0" maxOccurs="unbounded" processContents="skip" />
            </xs:sequence>
          </xs:complexType>
        </xs:element>
        <xs:element name="ResourceMap">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="VersionInfo">
                <xs:complexType>
                  <xs:anyAttribute processContents="skip" />
                </xs:complexType>
              </xs:element>
              <xs:element minOccurs="0" maxOccurs="unbounded" name="ResourceMapSubtree" type="scopeType" />
            </xs:sequence>
            <xs:attribute name="name" type="xs:string" use="required" />
            <xs:anyAttribute processContents="skip" />
          </xs:complexType>
        </xs:element>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>

MakePri.exe 支持转储类型“基本”、“详细”、“架构”和“摘要”。MakePri.exe supports dump types 'Basic', 'Detailed', 'Schema', and 'Summary'. 要配置 MakePri.exe 以发出 PriInfo 索引器可以读取的转储类型,则在使用 dump 命令时包括“详细 /DumpType”。To configure MakePri.exe to emit the dump type that the PriInfo indexer can read, include "/DumpType Detailed" when using the dump command.

MakePri.exe 跳过 .pri.xml 文件的多个元素。Several elements of the .pri.xml file are skipped by MakePri.exe. 这些元素在索引过程中进行计算,或在 MakePri.exe 配置文件中指定。These elements are either computed during indexing, or are specified in the MakePri.exe configuration file. 转储文件中包含的资源名称、限定符和值都直接在新的 PRI 文件中进行维护。Resource names, qualifiers, and values that are contained within the dump file are directly maintained in the new PRI file. 但是,顶级资源映射并不保留在最终 PRI 中。The top-level resource map, however, is not maintained in the final PRI. 资源映射合并为索引的一部分。Resource Maps are merged as part of the indexing.

这是来自转储文件的有效的字符串类型资源的示例。This is an example of a valid String type resource from a dump file.

<NamedResource name="SampleString " index="96" uri="ms-resource://SampleApp/resources/SampleString ">
  <Decision index="2">
    <QualifierSet index="1">
      <Qualifier name="Language" value="EN-US" priority="900" scoreAsDefault="1.0" index="1"/>
    </QualifierSet>
  </Decision>
  <Candidate type="String">
    <QualifierSet index="1">
      <Qualifier name="Language" value="EN-US" priority="900" scoreAsDefault="1.0" index="1"/>
    </QualifierSet>
    <Value>A Sample String Value</Value>
  </Candidate>
</NamedResource>

这是来自转储文件的具有两个候选项的有效的路径类型资源的示例。This is an example of a valid Path type resource with two candidates from a dump file.

<NamedResource name="Sample.png" index="77" uri="ms-resource://SampleApp/Files/Images/Sample.png">
  <Decision index="2">
    <QualifierSet index="1">
      <Qualifier name="Scale" value="180" priority="500" scoreAsDefault="1.0" index="1"/>
    </QualifierSet>
    <QualifierSet index="2">
      <Qualifier name="Scale" value="140" priority="500" scoreAsDefault="0.7" index="2"/>
    </QualifierSet>
  </Decision>
  <Candidate type="Path">
    <QualifierSet index="1">
      <Qualifier name="Scale" value="180" priority="500" scoreAsDefault="1.0" index="1"/>
    </QualifierSet>
    <Value>Images\Sample.scale-180.png</Value>
  </Candidate>
  <Candidate type="Path">
    <QualifierSet index="2">
      <Qualifier name="Scale" value="140" priority="500" scoreAsDefault="1.0" index="1"/>
    </QualifierSet>
    <Value>Images\Sample.scale-140.png</Value>
  </Candidate>
</NamedResource>

ResFilesResFiles

ResFiles 索引器由 RESFILES 的 type 属性进行标识。The ResFiles indexer is identified by a type attribute of RESFILES. 它索引 .resfiles 文件的内容。It indexes the contents of a .resfiles file. 它的配置元素符合以下架构。Its configuration element conforms to the following schema.

<xs:schema id="resx" xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
    <xs:simpleType name="IndexerConfigResFilesType">
        <xs:restriction base="xs:string">
            <xs:pattern value="((r|R)(e|E)(s|S)(f|F)(i|I)(l|L)(e|E)(s|S))"/>
        </xs:restriction>
    </xs:simpleType>
    <xs:element name="indexer-config">
        <xs:complexType>
            <xs:attribute name="type" type="IndexerConfigResFilesType" use="required"/>
            <xs:attribute name="qualifierDelimiter" type="xs:string" use="required"/>
        </xs:complexType>
    </xs:element>
</xs:schema>

.resfiles 文件是包含一个文件路径简单列表的文本文件。A .resfiles file is a text file containing a flat list of file paths. .resfiles 文件可以包含“//”评论。A .resfiles file can contain "//" comments. 下面是一个示例。Here's an example.

Strings\component1\fr\elements.resjson
Images\logo.scale-100.png
Images\logo.scale-140.png
Images\logo.scale-180.png

ResJSONResJSON

ResJSON 索引器由 RESJSON 的 type 属性进行标识。The ResJSON indexer is identified by a type attribute of RESJSON. 它索引 .resjson 文件的内容,这是字符串资源文件。It indexes the contents of a .resjson file, which is a string resource file. 它的配置元素符合以下架构。Its configuration element conforms to the following schema.

<xs:schema id="resjson" xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
    <xs:simpleType name="IndexerConfigResJsonType">
        <xs:restriction base="xs:string">
            <xs:pattern value="((r|R)(e|E)(s|S)(j|J)(s|S)(o|O)(n|N))"/>
        </xs:restriction>
    </xs:simpleType>
    <xs:element name="indexer-config">
        <xs:complexType>
            <xs:attribute name="type" type="IndexerConfigResJsonType" use="required"/>
            <xs:attribute name="initialPath" type="xs:string" use="optional"/>
        </xs:complexType>
    </xs:element>
</xs:schema>

.resjson 文件包含 JSON 文本(请参阅 JavaScript 对象表示法 (JSON) 的应用程序/json 媒体类型)。A .resjson file contains JSON text (see The application/json Media Type for JavaScript Object Notation (JSON)). 文件必须包含一个具有分层属性的简单 JSON 对象。The file must contain a single JSON object with hierarchical properties. 每个属性必须是另外一个 JSON 对象或字符串值。Each property must either be another JSON object or a string value.

名称以下划线(“”)开头的 JSON 属性不编译到最终 PRI 文件中,但保留在日志文件中。JSON properties with names that begin with an underscore ("") are not compiled into the final PRI file, but are maintained in the log file.

文件还可以包含“//”评论,该评论在分析过程中被忽略。The file can also contain "//" comments which are ignored during parsing.

initialPath 属性通过将此初始路径追加在资源名称前面的方式将所有资源放在此初始路径下。The initialPath attribute places all resources under this initial path by prepending it to the name of the resource. 这通常在为类库资源编制索引时会用到。You would typically use this when indexing class library resources. 默认为空。The default is blank.

ResWResW

ResW 索引器由 RESW 的 type 属性进行标识。The ResW indexer is identified by a type attribute of RESW. 它索引 .resw 文件的内容,这是字符串资源文件。It indexes the contents of a .resw file, which is a string resource file. 它的配置元素符合以下架构。Its configuration element conforms to the following schema.

<xs:schema id="resw" xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
    <xs:simpleType name="IndexerConfigResxType">
        <xs:restriction base="xs:string">
            <xs:pattern value="((r|R)(e|E)(s|S)(w|W))"/>
        </xs:restriction>
    </xs:simpleType>
    <xs:element name="indexer-config">
        <xs:complexType>
            <xs:attribute name="type" type="IndexerConfigResxType" use="required"/>
            <xs:attribute name="convertDotsToSlashes" type="xs:boolean" use="required"/>
            <xs:attribute name="initialPath" type="xs:string" use="optional"/>
        </xs:complexType>
    </xs:element>
</xs:schema>

.resw 文件是符合以下方案的 XML 文件。A .resw file is an XML file that conforms to the following schema.

  <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
    <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
    <xsd:element name="root" msdata:IsDataSet="true">
      <xsd:complexType>
        <xsd:choice maxOccurs="unbounded">
          <xsd:element name="metadata">
            <xsd:complexType>
              <xsd:sequence>
                <xsd:element name="value" type="xsd:string" minOccurs="0" />
              </xsd:sequence>
              <xsd:attribute name="name" use="required" type="xsd:string" />
              <xsd:attribute name="type" type="xsd:string" />
              <xsd:attribute name="mimetype" type="xsd:string" />
              <xsd:attribute ref="xml:space" />
            </xsd:complexType>
          </xsd:element>
          <xsd:element name="assembly">
            <xsd:complexType>
              <xsd:attribute name="alias" type="xsd:string" />
              <xsd:attribute name="name" type="xsd:string" />
            </xsd:complexType>
          </xsd:element>
          <xsd:element name="data">
            <xsd:complexType>
              <xsd:sequence>
                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
              </xsd:sequence>
              <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
              <xsd:attribute ref="xml:space" />
            </xsd:complexType>
          </xsd:element>
          <xsd:element name="resheader">
            <xsd:complexType>
              <xsd:sequence>
                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
              </xsd:sequence>
              <xsd:attribute name="name" type="xsd:string" use="required" />
            </xsd:complexType>
          </xsd:element>
        </xsd:choice>
      </xsd:complexType>
    </xsd:element>
  </xsd:schema>

convertDotsToSlashes 属性将在资源名称(数据元素名称属性)中找到的所有点(“.”)字符转换为正斜杠“/”,除非点字符位于“[”和“]”之间。The convertDotsToSlashes attribute converts all dot (".") characters found in resource names (data element name attributes) to a forward slash "/", except when the dot characters are between a "[" and "]".

initialPath 属性通过将此初始路径追加在资源名称前面的方式将所有资源放在此初始路径下。The initialPath attribute places all resources under this initial path by prepending it to the name of the resource. 这通常在为类库资源编制索引时用到。You typically use this when indexing class library resources. 默认为空。The default is blank.