[Content_types].xml 文件的结构The Structure of the [Content_types].xml File

包含有关 VSIX 包中的内容种类的信息。Contains information about the kinds of content in a VSIX package. Visual Studio 使用 [Content_Types] .xml 文件来安装包,但不会安装文件本身。Visual Studio uses the [Content_Types].xml file to install the package, but it does not install the file itself.


尽管本主题仅适用于 VSIX 包中使用的 [Content_Type] .xml 文件,但 [Content_Types] .xml 文件类型是 *开放打包约定 (OPC) * 标准的一部分。Although this topic applies only to [Content_Type].xml files that are used in VSIX packages, the [Content_Types].xml file type is part of the Open Packaging Conventions (OPC) standard. 有关详细信息,请参阅 MSDN 网站上的 OPC:用于打包数据的新标准For more information, see OPC: A New Standard For Packaging Your Data on the MSDN Web site.

特性和元素Attributes and Elements

以下各节描述了 root 元素及其属性和子元素。The following sections describe the root element and its attributes and child elements.

Root 元素Root Element

元素Element 描述Description
Types 包含枚举 VSIX 包中的文件类型的子元素。Contains child elements that enumerate the file types in the VSIX package.


属性Attribute 描述Description
Xmlns (必需。 ) 用于此 [Content_Types] .xml 文件的架构位置。(Required.) The location of the schema used for this [Content_Types].xml file.

{Attribute name}Attribute{Attribute name} Attribute

Value 描述Description
http://schemas.openformats.org/package/2006/content-types 内容类型架构的位置。The location of the content types schema.

子元素Child Elements

Types 元素可包含任意数量的 Default 元素。The Types element can contain any number of Default elements.

元素Element 描述Description
Default 描述 VSIX 包中的内容类型。Describes a content type in the VSIX package. 包中的每个文件类型都必须有其自身的 Default 元素。Every file type in the package must have its own Default element.


属性Attribute 描述Description
Extension VSIX 包中文件的文件扩展名。The file name extension of a file in the VSIX package.
ContentType 描述与文件扩展名关联的内容类型。Describes the kind of content that is associated with the file name extension.

{Attribute name}Attribute{Attribute name} Attribute

Visual Studio 可识别 ContentType 相关类型的以下值 ExtensionVisual Studio recognizes the following ContentType values for the associated Extension types.

分机Extension ContentTypeContentType
txttxt text/plaintext/plain
.pkgdefpkgdef text/plaintext/plain
xmlxml text/xmltext/xml
source.extension.vsixmanifestvsixmanifest text/xmltext/xml
htm 或 htmlhtm or html text/htmltext/html
rtfrtf 应用程序/rtfapplication/rtf
pdfpdf 应用程序/pdfapplication/pdf
GIFgif image/gifimage/gif
jpg 或 jpegjpg or jpeg image/jpgimage/jpg
tifftiff image/tiffimage/tiff
vsixvsix 应用程序/zipapplication/zip
zipzip 应用程序/zipapplication/zip
dlldll application/octet-streamapplication/octet-stream
所有其他文件类型all other file types application/octet-streamapplication/octet-stream



下面的 [Content_Types] .xml 文件描述了一个典型的 VSIX 包。The following [Content_Types].xml file describes a typical VSIX package.


<?xml version="1.0" encoding="utf-8" ?>
<Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types">
    <Default Extension="vsixmanifest" ContentType="text/xml" />
    <Default Extension="dll" ContentType="application/octet-stream" />
    <Default Extension="png" ContentType="application/octet-stream" />
    <Default Extension="txt" ContentType="text/plain" />
    <Default Extension="pkgdef" ContentType="text/plain" />

请参阅See also